0

i need to open IE and url. After that I need to click a link text with tag.

Private Sub CommandButton_Click() 

Dim IE As Object
Dim NewURL As String
Dim sURL As String
Dim strCountBody As String
Dim lStartPos As Long
Dim lEndPos As Long
Dim TextIWant As String
Application.ScreenUpdating = False
Set IE = CreateObject("Internetexplorer.Application")

sURL = "My Link" 'hidden for security reasons.
With IE
    .navigate sURL
    ' uncomment the line below if you want to watch the code execute, or for debugging
    .Visible = True
End With
' loop until the page finishes loading
Do While IE.Busy
Loop    

' click a text link on the page after that
Set ElementCol = IE.document.getElementsByTagName("a")
For Each link In ElementCol
    If link.innerHTML = "Link Text" Then
        NewURL = link.GetAttribute("href")
        Exit For
    End If
Next link
With IE
    .navigate NewURL
    ' uncomment the line below if you want to watch the code execute, or for debugging
    .Visible = True
End With
' loop until the page finishes loading
Do While IE.Busy
Loop

End Sub
Community
  • 1
  • 1

0 Answers0