0
程序工作正常(所需文本顯示在Excel中)。但之後,IE停止工作和運行時錯誤462(遠程服務器機器不存在或不可用)。在互聯網上搜索解決方案。 https://support.microsoft.com/en-us/kb/178510。 我無法有效更改代碼。將站點中的某些文本複製到Excel(運行時錯誤462)
Sub extractTablesData1()
Dim IE As Object
Dim Data As Object
Dim xlApp As Excel.Application
Dim xlwb As Excel.Workbook
Dim xlsh As Excel.Worksheet
Dim i As Integer
Dim elemCollection As Variant
Set xlApp = CreateObject("Excel.Application")
Set xlwb = xlApp.Workbooks("IESite.xlsx")
Set xlsh = xlwb.Worksheets("Data")
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = False
.navigate ("http://allscores.ru/soccer/new_ftour.php?champ=2404&f_team=406&tour=110")
While IE.ReadyState <> 4
DoEvents
Wend
Set Data = IE.document.getElementsbyTagName("table")(6).querySelectorAll("td.clr, td.clr_win, td.clr_draw, td.clr_loose")
i = 1
For Each elemCollection In Data
xlsh.Cells(34, 1 + i).Value = elemCollection.innerText
i = i + 1
Next elemCollection
End With
IE.Quit
Set IE = Nothing
結束子
我改變了代碼,然後我得到運行時錯誤9(下標越界) – maxim465
你改變'Workbook'的命名和「工作表」? – DragonSamu
我改了名字,然後我們回到原來的問題(IE停止工作,運行時錯誤462) – maxim465