伙计们,我在使用VBA代码单击锚点网站时遇到了麻烦。
我要单击的链接如下:
<a href="http://www.hapvida.com.br/pls/webhap/webNewTrocaArquivo.Download?pPessoa=36561410&pNoCache=1817001839&pIdSessao=001718093818134569635">BAIXAR ARQUIVOS - DOWNLOAD</a>
我尝试了几种方法,但是它们仅适用于网站上的其他链接,而不适用于该链接。
这是我的代码现在的样子:
Sub login()
Const Url$ = "https://www.hapvida.com.br/pls/webhap/webNewTrocaArquivo.login"
Dim UserName As String, Password As String, LoginData As Worksheet
Set LoginData = ThisWorkbook.Worksheets("1")
UserName = LoginData.Cells(2, "B").Value
Password = LoginData.Cells(3, "B").Value
Dim ie As InternetExplorer
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Navigate Url
ieBusy ie
.Visible = True
Dim oLogin As Object, oPassword As Object, oCodigo As Object
Set oLogin = .Document.getElementsByName("pCpf")(0)
Set oPassword = .Document.getElementsByName("pSenha")(0)
oLogin.Value = UserName
oPassword.Value = Password
.Document.forms(0).submit
End With
For Each l In ie.Document.getElementsByClassName("ultimas_noticias")
If l.tagName = "a" Then
l.Click
End If
Exit For
Next
End Sub
Sub ieBusy(ie As Object)
Do While ie.Busy Or ie.ReadyState < 4
DoEvents
Loop
End Sub
非常感谢