Solved

Web Browser Stuff

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

758 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

17 Experts available now in Live!

Get 1:1 Help Now