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
Solved

Web Browser Stuff

Posted on 2004-04-21
4
1,107 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

839 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