我需要打开IE和网址。之后,我需要点击带标签的链接文字。
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