错误显示为“对象变量或未设置块变量”

时间:2017-09-20 03:09:33

标签: vba excel-vba excel

在运行以下代码时,我在此行收到错误:

.noHover{
    pointer-events: none;
}

.h1Margin {
    margin-bottom: 4rem;
}

错误是:

  

对象变量或未设置块变量

变量appIE.document.getElementById("__tab_tabFilter").Click 应包含sathish之类的值。请建议我如何声明这个变量。此外,此代码需要运行1000次才能获取数据。

"ABC21A"

使用Sub macro() Dim appIE As Object Dim objElement As Object Dim Y As Long Dim obj As Object Dim r As Long, c As Long, t As Long Dim objCollection As Object Dim eRow As Long ' Create InternetExplorer Object Set appIE = CreateObject("InternetExplorer.Application") With appIE appIE.Visible = False appIE.navigate "website" Do While appIE.Busy Or appIE.ReadyState <> 4 DoEvents Loop appIE.Visible = True appIE.document.getElementById("Username").Value = "" appIE.document.getElementById("Password").Value = "" appIE.document.getElementById("btnSubmit").Click Number = Range("A1", Range("A1").End(xlDown)).Rows.Count For Y = 1 To Number sathish = Cells(Y, 1).Value appIE.document.getElementById("__tab_tabFilter").Click appIE.document.getElementById("filter_ReferenceCode").Value = sathish appIE.document.getElementById("filter_btnSetFilter").Click 'Set IE = Nothing Set objCollection = appIE.document.getElementsByTagName("TABLE") For t = 10 To (objCollection.Length - 1) For r = 0 To (objCollection(t).Rows.Length - 1) eRow = Sheet2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row For c = 0 To (objCollection(t).Rows(r).Cells.Length - 1) ThisWorkbook.Worksheets(2).Cells(eRow, c + 1) = objCollection(t).Rows(r).Cells(c).innerText Next c Next r If t = objCollection.Length - 1 Then Cells(eRow + 1, 1) = "" End If Next t Next Y End With ' Set IE = Nothing End Sub 我得到相同的“对象变量或没有设置块变量”错误:

Option Explicit

HTML:

appIE.document.getElementById("__tab_tabFilter").Click

0 个答案:

没有答案