?
Solved

Web Browser Stuff

Posted on 2004-04-21
4
Medium Priority
?
1,113 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 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