Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to make WebBrowser1.Document.Links(1).Click work

Status
Not open for further replies.

anddos

Programmer
Sep 5, 2004
13
GB
so far i have this code , now its not clicking the link properly it just flashs and dosent go on to the next site when its clicked , anyone know the problem

Option Explicit


Private Sub Form_Load()
WebBrowser1.Navigate "http"

End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)

WebBrowser1.Document.Links(1).Click

End Sub
 
As far as I can see your code is currently clicking the named link everytime a webpage loads and I suspect that the link on the second page when clicked sends you back to the first page.
Try this with Google as the page you navigate to on Form_Load and see the pages constantly change.

Try this:
Code:
Dim Loaded As Boolean

Private Sub Form_Load()
Loaded = False
WebBrowser1.Navigate "http"
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If Loaded = False Then
WebBrowser1.Document.Links(1).Click
Loaded = True
End If
End Sub

Hope this helps

Harleyquinn

---------------------------------
For tsunami relief donations
 
when its compiled to a exe it says
object varible or with block varible not set
any ideas
this is the code
Dim Loaded As Boolean

Private Sub Form_Load()
Loaded = False
WebBrowser1.Navigate ""
End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If Loaded = False Then
WebBrowser1.Document.Links(1).Click
Loaded = True
End If
End Sub
 
hmm ok well its not a image gif file or its not a txt link , its like a box with mouse over and link inside it
how would i make it click this
 
or can i make it click on a certain word on the webpage etc
costa rica or costa rica travel
i need to make it click these
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top