FeVeR
asked on
Web Browser Stuff
Hi, I have:
Sub Main()
Me.Show
WebBrowser1.navigate "http://www.aanet.com.au/members/index.htm"
'sometimes there are timing issues, so issue a couple of doevents so the browser responds
DoEvents: DoEvents: DoEvents
Do While WebBrowser1.Busy 'wait until the page loads by looping
DoEvents
Loop
Set doc = WebBrowser1.document 'access the document properties of the current page
DoEvents
Do While WebBrowser1.Busy
DoEvents
Loop
'if you pull your page up in IE and you view the source,
'you can find the form variables that you want to fill in
'I'm sure there are other ways to iterate through the form
' to get them, but I never could figure it out.
returnValue = FillForm("username", "myname", False)
returnValue = FillForm("password", "mypass", False)
WebBrowser1.document.Forms ("form1"). submit <-----PROBLEM
End Sub
Public Sub ClickLink(doc, LinkText As String)
For i = 0 To doc.links.length - 1
If InStr(LTrim(RTrim(doc.link s(i).outer Text)), LinkText) > 0 Then
doc.links(i).Click
Exit For
End If
Next i
End Sub
Function FillForm(ByVal formtag, ByVal FillValue, ByVal isCombo As Boolean) As Boolean
Dim elemcollection As IHTMLElementCollection
Dim obj As Object
Dim element2 As HTMLInputElement
Dim element As HTMLInputElement
If Not isCombo Then
WebBrowser1.document.Forms (0).elemen ts(formtag ).Value = FillValue
Else
WebBrowser1.document.Forms (0).elemen ts(formtag ).selected Index = Val(FillValue)
End If
End Function
My problem is that the "Login" button is not being clicked - and i get an error!?
Why is this? Should I use WebBrowser1.Document.Forms (0).Elemen ts(1).Clic k? - does work either!
Sub Main()
Me.Show
WebBrowser1.navigate "http://www.aanet.com.au/members/index.htm"
'sometimes there are timing issues, so issue a couple of doevents so the browser responds
DoEvents: DoEvents: DoEvents
Do While WebBrowser1.Busy 'wait until the page loads by looping
DoEvents
Loop
Set doc = WebBrowser1.document 'access the document properties of the current page
DoEvents
Do While WebBrowser1.Busy
DoEvents
Loop
'if you pull your page up in IE and you view the source,
'you can find the form variables that you want to fill in
'I'm sure there are other ways to iterate through the form
' to get them, but I never could figure it out.
returnValue = FillForm("username", "myname", False)
returnValue = FillForm("password", "mypass", False)
WebBrowser1.document.Forms
End Sub
Public Sub ClickLink(doc, LinkText As String)
For i = 0 To doc.links.length - 1
If InStr(LTrim(RTrim(doc.link
doc.links(i).Click
Exit For
End If
Next i
End Sub
Function FillForm(ByVal formtag, ByVal FillValue, ByVal isCombo As Boolean) As Boolean
Dim elemcollection As IHTMLElementCollection
Dim obj As Object
Dim element2 As HTMLInputElement
Dim element As HTMLInputElement
If Not isCombo Then
WebBrowser1.document.Forms
Else
WebBrowser1.document.Forms
End If
End Function
My problem is that the "Login" button is not being clicked - and i get an error!?
Why is this? Should I use WebBrowser1.Document.Forms
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
How do i make the program wait until the click has been processed before contintuing?
Do
DoEvents
Loop while Webbrowser.Busy
DoEvents
Loop while Webbrowser.Busy
WebBrowser1.Document.Forms
if not, you might try
WebBrowser1.Document.Forms