html - 单击锚链接 Excel VBA
问题描述
伙计们,我在使用 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
非常感谢提前
解决方案
推荐阅读
- mongodb - MongoDB Atlas 触发器未设置字段
- batch-file - 将文件列表从目录+子文件夹复制到另一个文件夹
- corda - 如何使corda Vault查询返回令牌总和或总计
- javascript - React JS Material UI 自动完成:更改选项
- flutter - 在颤动中创建自定义阴影
- java - 为什么JVM在解析非接口方法时会考虑超接口?(JVM 5.4.3.3)
- kotlin - Kotlin:必须初始化变量“结果”
- oracle - 表空间'USERS'没有权限,而我的表空间是别的东西
- react-native - React Navigation V5 Conditional Navigator 屏幕基于异步存储值
- kubernetes - K8s:app.kubernetes.io 实例标签目的