尝试修改刮宏以单击网页上的按钮。我在下面的代码中收到错误91,并且不能为我的生活找出原因。它不喜欢的对象是“dd”对象。我已经尝试了迄今为止在这里看到的所有内容,所以任何新颖的想法都将非常感谢!VBA宏“对象变量或未设置块变量”无法找出原因
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.EnableEvents = True
Dim wb1 As Workbook
Dim ws1 As Worksheet
Dim MyURL As String
Dim Rows As Long, links As Variant, IE As InternetExplorer, link As Variant
Dim i As Long
Dim sID As String
Dim rngLinks As Range, rngLink As Range
Dim filterRange As Range
Dim copyRange As Range
Set wb1 = ThisWorkbook
Set ws1 = wb1.Worksheets("Sheet1")
Set IE = New InternetExplorer
Rows = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row
Set rngLinks = ws1.Range("E2:E" & Rows)
i = 2
With IE
.Visible = True
.navigate ("https://www.samplesite.com/account/update")
While .Busy Or .readyState <> 4: DoEvents: Wend
Application.Wait (Now() + TimeValue("00:00:006"))
Dim doc As Object
Set doc = IE.document
Dim classNameElem As Variant
Dim tagNameElem As Variant
Set classNameElem = doc.getElementsByClassName("thisisaclass")(0)
If (classNameElem <> Null) Then
Set tagNameElem = classNameElem.getElementsByTagName("input")(0)
End If
If (tagNameElem <> Null) Then
tagNameElem.Click
End If
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.EnableEvents = True
ws1.Activate
Set rngLinks = Nothing
End Sub
尝试从'Set dd'或Dim dd'设置'Set'作为'Object'。 – Bathsheba
感谢您的提示,我已经尝试了两种修复方法。我也尝试调暗为一个字符串。 –
该行末尾的“Click”看起来很奇怪。看起来像一个不返回值的函数。 – Bathsheba