PDA

View Full Version : Issue trying to click link on a page



frustrating
12-04-2012, 08:09 PM
Hello
I am trying to figure out the best way to automate the click of a link.

Basically what I want is to open the browser to a specific page and search for a pdf file (which is named arbitrarily) and click on it.

I adjusted my code a bit, and now it at least finds the link:

Code:
Private Sub Text282_Click() Dim IeApp As InternetExplorer Dim sURL As String Dim IeDoc As Object Dim Element As HTMLLinkElement Set IeApp = New InternetExplorer IeApp.Visible = True sURL = "link" IeApp.navigate sURL Do Loop Until IeApp.ReadyState = READYSTATE_COMPLETE Set IeDoc = IeApp.Document For Each Element In IeDoc.links If InStr(Element.innerText, ".pdf") Then Call Element.Click Exit For End If Next Element End Sub

But the opened browser closes immediately after the link gets clicked! Weird