Excel和VBA:运行时错误91:使用MSXML2进行解析

时间:2016-04-12 05:03:46

标签: xml vba msxml

下面的代码在我的Windows 8平板电脑(Office 2013)上运行得非常好,但运行Windows 7(Office 2010)的笔记本电脑要慢得多(25%)。代码分解为    直到lx = .rows.length - 1

然而,如前所述,它适用于一个系统但不适用于另一个系统。此外,我可以更改日期,它的工作正常。任何和所有的帮助将不胜感激,谢谢。

Dim strTeamBatting As String
Dim html As Object
Dim strPlayer As String
Dim lx, ly As Long
Dim iResult As Integer
Dim strResult As String

Set html = CreateObject("htmlFile")

With CreateObject("msxml2.xmlhttp")
     .Open "GET", "http://www.baseball-reference.com/boxes/ARI/ARI201604100.shtml", False
     .send
     html.body.innerhtml = .responsetext
End With

strTeamBatting = "ChicagoCubsbatting"

With html.getelementbyid(strTeamBatting)
     lx = 0
Do Until lx = .Rows.Length - 1
    strPlayer = .Rows(lx).Cells(0).innertext
        If strPlayer <> "Batting" Then
            msgbox(strplayer)     
            Else
        End If
lx = lx + 1
Loop
End With

更新

我忘了在那里有必要的网址,所以我把它添加到了正确的位置。我还确保我安装并引用了msxml 6.0,但仍然没有运气。

0 个答案:

没有答案