ش | ی | د | س | چ | پ | ج |
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
کد زیر دیالوگ باکسی برای گرفتن یک فایل باز می کند
Private Sub lblBrowse_Click()
'declare file dialog with late binding ->
Dim fDialog As Object, strPath As String
Set fDialog = Application.FileDialog(3) 'msoFilePicker
'set parameters ->
Me.wbContent.ControlSource = ""
'initializing the file dialog ->
With fDialog
.AllowMultiSelect = False
.Filters.Clear '
.title = "Please select a file..."
'display the dialog box. If the .Show method returns True
'the user picked a file. If the .Show method returns False
'the user clicked Cancel.
If .show = True Then
strPath = .SelectedItems(1)
Debug.Print "SELECTED_FILE: " & strPath
'set source property to the string containing the full path ->
Me.wbContent.ControlSource = strPath
Me.wbContent.Requery
Else
End If
End With
البته جواب نمیدهد خودتان را خسته نکنید ممکن است برای بعضی در WebBrowser نمایش داده شود.
Me.wbContent.ControlSource = "='" & strPath & "'"
WebBrowserControl.ControlSource Property :
روی چک باکس یا Toggle Button عمل نمیکند ( ControlSource )
استفاده از پراپرتی ControlSource برای نمایش داده در کنترل
نمایش و ویرایش داده متصل به یک جدول کوئری یا عبارت Sql یا نمایش نتیجه یک عبارت .( فرضا حاصلضرب دو تکست باکس یا فیلد از جدول یاکوئری)
You can use the ControlSource property to specify what data appears in a control. You can display and edit data bound to a field in a table, query, or SQL statement. You can also display the result of an expression. Read/write String.
Navigate2 Method --->> internet-explorer
NavigateComplete2 event --->> internet-explorer
expression.DocumentComplete (pDisp, URL)
pDisp ( Required,Object)
A pointer to the IDispatch interface of the window or frame in which the document is loaded.
URL (Required,Variant)
Contains the URL of the loaded document.
Return value : Nothing
ByVal pDisp As Object
ByVal Url As Variant
Private Sub object_DocumentComplete( _ ByVal pDisp As Object, _ ByVal URL As Variant)
Set wb = WebBrowser0.Object
wb.Silent = True
With wb
.Navigate2 "about:blank"
Do Until .ReadyState = 4 '=READYSTATE_COMPLETE
'This is a somewhat inefficient way to wait, but loading a blank page should only take a couple of milliseconds
DoEvents
Loop
.Document.Open
.Document.Write "<!DOCTYPE html><HTML><HEAD><TITLE>My title</TITLE></HEAD><BODY scroll=""auto"" style=""margin: 0px; padding: 0px;"">" & _
"<embed src=""" & fileLocation & """ width=""100%"" height=""100%"" />" & _
"</BODY></HTML>"
.Document.Close
End With
With Me.WebBrowser0.Object.Document.Open
.Write "<html><head></head><body><p>Some content.</p></body></html>"
.Close
End With
Opening A Blank Page
Me.WebBrowser0.ControlSource = "about:blank"
Me.WebBrowser0.Object.Document.parentWindow.execScript ("alert('Your Access Database " & Application.CurrentProject.Name & " rocks!');")
Me.WebBrowser0.Object.Document.body...
<!DOCTYPE html> <!-- saved from url=(0016)http://localhost --> <html> <head>
بخوانید و لذت ببرید
جمع آوری از سایت های مختلف
OnLoad :
WebBrowser1.Navigate ("http://www.vbcity.com/forums/active.asp";) 'Replace with URL
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Next
Public WithEvents hDoc As MSHTML.HTMLDocument
Hdoc_ContextMenu=False
می توانید طبق لینک بالا لوپ را باکدهای HtmlDocument انجام بدهید ؟ در نظرات کد و نتیجه آن را مرقوم بفرمائید.
Dim HTML As HTMLDocument
Set HTML = WebBrowser1.Document HTML.All.Item("UNTextbox").Value = "UserName"
HTML.All.Item("PWTextbox").Value = "Password"
HTML.All.Item("LoginButton").Click
ورود داده به باکس UserName :
Me.WebBrowser1.Navigate="Url" ' if be true
Me.WebBrowser1.Document.All("UserName").Value = "tester"
For Each ele In WebBrowser1.document.getelementsbytagname("a")
If ele.innertext = "Log Out" Then
Private WithEvents m_body As MSHTML.HTMLBody
MsgBox "You clicked the page's body", vbInformationPrivate Function m_body_onclick() As Boolean
End Function
Web Browsing Objects htm
WebBrowser.GoForward Method webbrowser
WebBrowser.GoBack Method webbrowser
Me.WebBrowser1.Document.Window.ScrollTo(0, 300)
WebBrowser1.Document.body.Scroll = "no"
CommandStateChange : برای فعال یا غیرفعال کردن دکمه های Forward و Back در مرورگر استفاده می شود . شکل کلی فراخوانی این event بصورت زیر است :
Re: Disable webbrowser
Private Sub WebBrowser1_BeforeNavigate2(ByVa pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
If Me.Visible Then Cancel = True