webbrowser control problem

chris9104

New member
Local time
Today, 07:54
Joined
Nov 13, 2010
Messages
4
I can control the input to fields on a web page fine if using a new IE window with the following code:

Code:
    Dim IE As Object
    Dim URL As String
 
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    URL = "example"
    IE.navigate (URL)
    Do While IE.ReadyState <> 4 And IE.Busy
        DoEvents
    Loop
    IE.Document.all.Item("username").Value = "xxxx"
    IE.Document.all.Item("password").Value = "xxxx"
    IE.Document.Forms(1).submit

However I am now trying to do the same with the web browser control in access 2010 with
Code:
[COLOR=black]Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)[/COLOR]
[COLOR=red]WebBrowser1.Document[/COLOR].all.Item("username").Value = "xxxx"
WebBrowser1.Document.all.Item("password").Value = "xxxx"
WebBrowser1.Document.Forms(1).submit

End Sub
but get the error on the highlighted code, "method or data member not found"

Any ideas??
 
I think you'll want to use the pDisp object that's passed into the DocumentComplete event handler. That contains that document you want to use, but check the URLs too, because a page can contain many documents, and this event fires for each of them.
 
Well I've found out that the the code is firing twice, which I think means theres 2 frames on the webpage, I only want it to fire one the page is fully loaded.

I dont understand how to use pdisp, please can you explain?
 
Open the Locals window in the IDE. Set a breakpoint in the DocumentComplete event handler. Run your code.
Eventually the DocumentComplete event will fire and your code execution will hit your breakpoint. Now, take a look at the pDisp object as it appears in the locals window. It's an object that contains other objects so it's a treeview representing the document that completed and that fired the DocumentComplete event. One of the child objects is the Document object.
Cheers,
Mark
 

Users who are viewing this thread

Back
Top Bottom