When I click 'Open', it doesn't want to. It doesn't show any errors or anything, nothing happens.
VB Code:
Private Sub menuFileOpen_Click() wWeb.ExecWB OLECMDID_OPEN, OLECMDEXECOPT_PROMPTUSER End Sub
Can anyone help me?
When I click 'Open', it doesn't want to. It doesn't show any errors or anything, nothing happens.
VB Code:
Private Sub menuFileOpen_Click() wWeb.ExecWB OLECMDID_OPEN, OLECMDEXECOPT_PROMPTUSER End Sub
Can anyone help me?
Hello,
I'm using this code from a previous example in thread.
Private Sub Command1_Click()
WebBrowser1.Document.All("q").focus
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.google.com/"
End Sub
It all works great. But due to the lack of documentatiion I can seem to find a way of entering something in the text box and then reloading the page. Any help would be greatly appreciated. Or even a link to some documentation would work too.
Thanks
Figured it out. Just in case anyone is interested, this works.
Cheers...Code:WebBrowser1.Document.All("q").focus WebBrowser1.Document.All("q").Value = "blah blah" WebBrowser1.Document.All("btng").focus WebBrowser1.Document.activeElement.Click
i keep getting an Error 91 message. Anyone know why?
The codes here dont seem to be working for me. I can get the page loaded using:
but nothing fills in and i get the error 91 message the .Document.Forms(0) lineCode:Private Sub Command0_Click() Dim webBrowser1 As WebBrowser Set webBrowser1 = New WebBrowser Set webBrowser1 = CreateObject("InternetExplorer.Application") With webBrowser1 .Navigate "http://www.ncl.com/edocs" .Visible = True .Document.Forms(0).all("txtResID").focus .Document.Forms(0).all("txtResID").Value = "blah blah" End With End Sub
Try making the following changes....Code:.Document.all("txtResID").focus .Document.all("txtResID").Value = "blah blah"
now i get an error that says "Runtime error -2147467259 (80004005) Autmation Error Unspecified Error)
This won't load IE but use the webbrowser control in the form.Code:Private Sub Form_Load() WebBrowser1.Navigate "http://www.ncl.com/edocs" End Sub Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) With WebBrowser1 .Document.Forms(0).All("txtResID").focus .Document.Forms(0).All("txtResID").Value = "blah blah" End With End Sub
That code tells me WebBrowser1 is not defined. Don't i need to dim it somewhere?
bwt - im using VB through MS Access.
Ahhhh..Ok. Let me think about this because my code works fine in VB. I tested it.
Do you have access to the "microsoft internet control", ieframe.dll? If so, just add it to your project and that will be the end of it.
yes i have that added.
im using the microsoft internet control library, but its called "shdocvw.dll". What is "ieframe.dll"?
Let me try a few things in Access..
Sorry about the ieframe thing. You're right, it's shdocvw.dll.
thank you for helping me out with this. I've been going nuts for the past week trying to get this to work!
In Access i have a button that launchs this code OnClick (if that helps any).
Well..I'm new to Access 2007 (sometimes hard to figure where things are in a new version) and I don't see the internet control component and I've tried a few things but I can't seem to add it. So I have no way of helping you in Access.
My guess as to what your problem is that you're trying to access the text box before the page is fully loaded. Add the navigate command to the form_load part (get rid of it from the button click event). Once the page is fully loaded, click your button. Hope this helps.
in the VB editor: Tools > References > Microsoft Internet Controls.
i tried adding:
to make sure the page was fully loaded, but that doesnt work either.Code:Do Until webBrowser1.Busy = False Do Events Loop
I got that far but I can't actually add the component to the form. Were you able to actually add the component to your form? Are you using Access 2007?
im using Access 2003. To add it to the form, you just make sure the box next to it is checked, yes?
i definitely think my problem is that its not waiting for the browser to stop loading.
if i add an If webBrowser1.Busy = False statement around my .document lines, i get no error, but at the same time it doesnt fill in the fields.
If I were using 2003 I wouldn't have any problems. Welcome to the World of 2007. If I figure it out I will post back..
ok thats definitely my problem. I found a sub ruitine that Pauses for given amount of time, so i made it pause for 10 seconds, and it works!
Except, thats not a very reliable way of doing it in case the page takes a longer time to load for some reason.
how can i just have it check that the page is done and completely loaded?
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
FYI. My toolbox in Access is greyed out and I can't get to it..Seems like there's lots of others in my situation out there...Code:With WebBrowser1 .Document.Forms(0).All("txtResID").focus .Document.Forms(0).All("txtResID").Value = "blah blah" End With End Sub
ok it definitely works now.
to make it wait i used:
but now i need to figure how to click the "submit" button on the page. How do i go about that?Code:Do Until webbrowser1.ReadyState = READYSTATE_COMPLETE DoEvents Loop
I'm trying to use the "Check if word/string is found on page" code on the first page of this thread, but keep getting an Error 91 message on this line:
First i got an object not defined error because "webBrowser1" wasnt Dim'd, so i dim'd it as "Dim webBrowser1 as webbrowser" but now i need to SET it to something - i just dont know what i SET it to. Anyone know?Code:For i = 1 To WebBrowser1.Document.All.length
I realize this may sound odd...but can the Webbrowser Control be embedded in a HTML page? If so how would I do it?
I'm building a Folder Home Page to replace my Outlook Today and would like to be able to use it as a file browser right on the page.
Use an iframe element.Originally Posted by dch31969
Ok...I know how to put an iframe into a HTML page, but given that I had no idea until yesterday that the WebBrowser control existed, could you please provide me with the syntax? I should be able to figure things out from there.Originally Posted by penagate
sorry, I didn't mean embed the WebBrowser using an iframe, but just point the iframe to the directory you want to browse.
So its not possible to present an Explorer like interface complete with folders, drives, files? I'm essentially looking give my users everything that they have when they explore their PCs.Originally Posted by penagate
That auto submit thing is good With WebBrowser but how do u find the exact Thing to be written like. If i do it on. http://login.yahoo.com Then if i view html code for this page i see Document.Write. So I write it like this
WebBrowser1.Document.Write.passwd.value = strpw
passwd is PASSWORD so it doesnt work![]()
Nvm It Works Thanks For The Help By msgjp7
Hi, if you know, I need some codes! For the find box (when I start the find box and start searching a word, I want webbrowser to highlight it). I need codes for the right click menu, such as 'Save Picture As...'; 'E-mail Picture'; 'Print Picture'; 'Set as Background'; 'Set as Desktop Item'; 'Copy Shortcut'; 'Add to favorites'; 'Open link'; 'Open link in new window'; 'Save Target as...'; 'Print Target'. I want to know, if I have open form1, how to open a NEW form1 with a commandbutton? Please help with these problems!
Is there any way to block pop ups.???![]()
If my post was helpful to you, then express your gratitude using Rate this Post.
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD Athlon X2 5200+, ASUS Motherboard, 2 GB RAM, 400 GB HDD, Nvidia 8600 GT 512MB, 19.5" TFT(Wide), Creative 5.1 Home Theater
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, VB6, Photoshop...
Here is my current code:
Basically, supposed to replace every Google string with Boogle. Works, as I tested with MsgBox, but the thing is EHTML doesnt writeback to the page, so EHTML is changed, while whats being displayed isn't. Any way to writeback the changes without reloading the page?Code:Option Explicit Dim doc As HTMLDocument Private Sub Command1_Click() WebBrowser1.Navigate "http://www.google.com" End Sub Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Dim i As Long, EHTML For i = 1 To WebBrowser1.Document.All.length Set EHTML = _ WebBrowser1.Document.All.Item(i) If Not (EHTML Is Nothing) Then If InStr(1, EHTML.innerHTML, "Google", vbTextCompare) > 0 Then Replace EHTML.innerHTML, "Google", "Boogle" End If End If Next i doc = WebBrowser1.Document End Sub
Might be bringing an old post back alive but I definately needed help with this. The above code got me started on making my own context menu for the webbrowser control. However, My webbrowser control page that it navigates to has an iframe. When I right click on the iframe it does not keep the contextmenu, is there a way to fix this?Custom Right Click Menu
This is an example show how to make your own custom right click menu. in order for this to work you must add the "Must Add Microsoft HTML Object Library" to your refrance.Also make your own custom menu using the menu editor I named my "mnu"
Please Note it will effect all the context menus in the webbrowser.
VB Code:
'Must Add Microsoft HTML Object Library Option Explicit Public WithEvents HTML As HTMLDocument Private Function HTML_oncontextmenu() As Boolean HTML_oncontextmenu = False PopupMenu mnu '<---Check the mnu to your own menu name End Function Private Sub Form_Load() WebBrowser1.Navigate "www.google.com" End Sub Private Sub Form_Unload(Cancel As Integer) Set HTML = Nothing End Sub Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, _ URL As Variant) Set HTML = WebBrowser1.Document End Sub
Thanks,
n3m.
So, does you example work with IFrames?
Nevermind, I see now you stated that. BTW: I have been working on that problem from your other thread and so far no luck but I am sticking with it since I have learned a few things about frames and things since then so maybe, just maybe, I might be able to figure it iut.
Hi. Is there anyway any to get "updated" html code on pages with AJAX? Im working with .net 2008, Webbrowser.
Is there any workarround to solve this?
Thanks.
Ariel
Hi all,
Thanks for the control tips and examples. I'm developing an Outlook-Addin in VB6 and I'm trying to do what is outlined in 'Making page on startup' as listed below. I'm retriving HTML from a database and would like to display it in the webbrowser control.
The problem is that I have no intellisense past WebBrowser1.Document (no .Write). and when I add it, the program errors out.Code:Private Sub Form_Load() WebBrowser1.Navigate "about:blank" End Sub Private Sub Command1_Click() Dim HTML As String '----------The HTML CODE GOES FROM HERE AND DOWN---------- HTML = "<HTML>" & _ "<TITLE>Page On Load</TITLE>" & _ "<BODY>" & _ "<FONT COLOR = BLUE>" & _ "This is a " & _ "<FONT SIZE = 5>" & _ "<B>" & _ "programmatically " & _ "</B>" & _ "</FONT SIZE>" & _ "made page" & _ "</FONT>" & _ "</BODY>" & _ "</HTML>" '----------The HTML CODE GOES HERE AND ABOVE---------- WebBrowser1.Document.Write HTML End Sub
I have a reference to the Microsoft Internet Controls, but I don't know what is the matter.
Any help would be appreciated.
Thanks,
JB
JazzBass
In the .NET era
Trying to remember VB6
Progress:![]()
![]()
![]()
XP Professional @ Home
and @ the Office
Here's 2 additions:
Requires MSHTML Object Library and the WebBrowser is called wbMain
Waiting for a webpage to load
Code:cNavAndWaitvb Code:
Option Explicit Private Declare Function GetTickCount Lib "kernel32.dll" () As Long Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long) Private m_bDOMReady As Boolean Private WithEvents m_ctlWB As WebBrowser Public Function navigateAndWait(ByVal ctlWebBrowser As WebBrowser, ByRef vData As Variant, Optional ByRef lMaxWaitTimeMillis As Long = 45000) As Boolean On Error GoTo EH Dim lEndTime As Long, obj As IHTMLElement, szURL As String '--Navigate and wait for the web page to load '--vData can be a string(url) or an HTML Object Set m_ctlWB = ctlWebBrowser If (IsObject(vData)) Then Set obj = vData Select Case UCase(obj.tagName) '--Hyperlink reference, like links on a page Case "A" Call ctlWebBrowser.Navigate(obj.href) '--Forms, like login pages Case "FORM" Call obj.submit '--Something else, so try to click it Case Else Call obj.Click End Select Else '--Regular URL szURL = CStr(vData) Call ctlWebBrowser.Navigate(szURL) End If lEndTime = (GetTickCount() + lMaxWaitTimeMillis) m_bDOMReady = False Do While (Not m_bDOMReady) '--Check for timeout If ((lMaxWaitTimeMillis <> -1) And (GetTickCount() > lEndTime)) Then Exit Do '--So app doesnt freeze DoEvents '--Dont kill the CPU Call Sleep(5) Loop If (Not m_bDOMReady) Then Call m_ctlWB.Stop End If Set m_ctlWB = Nothing navigateAndWait = (m_bDOMReady) Exit Function EH: Call Err.Clear navigateAndWait = False End Function Private Sub m_ctlWB_DocumentComplete(ByVal pDisp As Object, URL As Variant) On Error GoTo EH Dim oHTMLDoc As HTMLDocument '--In pages with no frames, this event fires one time after loading is complete. '--In pages where multiple frames are loaded, this event fires for each frame where the DWebBrowserEvents2::DownloadBegin event has fired. '--The top-level frame fires the DocumentComplete in the end. '--So, to check if a page is done downloading, you need to check if the IDispatch* parameter, is same as the IDispatch of the WebBrowser control. If (pDisp Is m_ctlWB.object) Then m_bDOMReady = True ElseIf (TypeOf pDisp.Container Is HTMLDocument) Then Set oHTMLDoc = pDisp.Container If (oHTMLDoc.frames.length = 0) Then m_bDOMReady = True End If End If Exit Sub EH: Call Err.Clear End Sub
Example:
vb Code:
Private Sub cmdGo_Click() Dim oNAW As cNavAndWait, sStart As Single Set oNAW = New cNavAndWait sStart = Timer() Call oNAW.navigateAndWait(wbMain, txtURL.Text) Call MsgBox(txtURL.Text + " took " + CStr(Timer() - sStart) + " seconds to load.", vbOKOnly Or vbInformation, "Navigate And Wait") Set oNAW = Nothing End Sub
How to copy and save an image from a webpage
vb Code:
Option Explicit Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long) Private m_bDOMRdy As Boolean Private Sub cmdCopy_Click() Dim pDoc As HTMLDocument, pImgEle As IHTMLImgElement, pCR As IHTMLControlRange, szImgname As String '--Grab the image of the first picture on the page and copy it into the PictureBox Set pDoc = wbMain.Document For Each pImgEle In pDoc.All.tags("IMG") szImgname = Mid(pImgEle.src, InStrRev(pImgEle.src, "/") + 1) '--Create a control range '--MSDN: Contains a range of control type elements that is used for control selection; _ and represents an array of controls that can be operated on as a group. Set pCR = pDoc.body.createControlRange() '--Clear the clipboard Call Clipboard.Clear '--Add the image element Call pCR.Add(pImgEle) '--Copy it to the clipboard Call pCR.execCommand("copy") '--Do what you want with the image since its on the clipboard Set pbPic.Picture = Clipboard.GetData(vbCFBitmap) '--Save the image Call SavePicture(pbPic.Picture, "C:\" + szImgname) Exit For Next pImgEle End Sub Private Sub Form_Load() m_bDOMRdy = False Call wbMain.Navigate("http://frontrowcrew.com/") Do While (Not m_bDOMRdy) DoEvents Call Sleep(10) Loop End Sub Private Sub wbMain_DocumentComplete(ByVal pDisp As Object, URL As Variant) If (pDisp Is wbMain.Object) Then m_bDOMRdy = True End If End Sub