Link to home
Start Free TrialLog in
Avatar of FeVeR
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.links(i).outerText)), 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).elements(formtag).Value = FillValue
 
Else
  WebBrowser1.document.Forms(0).elements(formtag).selectedIndex = 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).Elements(1).Click? - does work either!
Avatar of scator
scator

it's been a while since I fiddled with this

WebBrowser1.Document.Forms(0).Loginbuttonname.click should work

if not, you might try

WebBrowser1.Document.Forms(0).submit
ASKER CERTIFIED SOLUTION
Avatar of bingie
bingie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of FeVeR

ASKER

How do i make the program wait until the click has been processed before contintuing?
Do
  DoEvents
Loop while Webbrowser.Busy