Solved

Web Browser Stuff

Posted on 2004-04-21
4
1,104 Views
Last Modified: 2010-05-02
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!
0
Comment
Question by:FeVeR
  • 2
4 Comments
 

Expert Comment

by:scator
ID: 10877580
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
0
 
LVL 11

Accepted Solution

by:
bingie earned 125 total points
ID: 10883427
This will do what you want perfectly :-)

I think you have been over-complicating it. Use this

WebBrowser1.Document.All("username").Value = username
WebBrowser1.Document.All("password").Value = password
WebBrowser1.Document.All("Submit").Click
0
 

Author Comment

by:FeVeR
ID: 10885920
How do i make the program wait until the click has been processed before contintuing?
0
 
LVL 11

Expert Comment

by:bingie
ID: 10887918
Do
  DoEvents
Loop while Webbrowser.Busy
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now