您好我正在尝试使用以下代码
在excel VBA中打开一个URLPublic Sub downloadCode()
Dim xHttp As MSXML2.XMLHTTP
Dim hdoc As MSHTML.HTMLDocument
Dim hElem As MSHTML.HTMLGenericElement
Set xHttp = New MSXML2.XMLHTTP
URL = Sheet8.Range("U3").value
If InStr(URL, "ebay.co.uk") = 0 Then
MsgBox ("Invalid Ebay Link. Row:" & i)
Exit Sub
End If
xHttp.Open "GET", URL
xHttp.send
Do
DoEvents
Loop Until xHttp.ReadyState = 4
'put into an htmldocument object
Set hdoc = New MSHTML.HTMLDocument
hdoc.body.innerHTML = xHttp.responseText
xHttp.abort
Dim MyFile1, fnum1
MyFile1 = "C:\hp\outputFromExcel1.txt"
fnum1 = FreeFile()
Open MyFile1 For Output As fnum1
Print #fnum1, hdoc.body.innerHTML
Close #fnum1
Shell "C:\WINDOWS\explorer.exe """ & MyFile1 & "", vbNormalFocus
End Sub
我的浏览器是带有Windows7的IE9,但是它在一台PC上返回正确的数据,但是在另一台具有相同配置的PC上有不同的数据,这可能是错的?我在浏览器中打开了URL,它们的HTML源代码相同。