【发布时间】:2014-11-26 02:17:46
【问题描述】:
我正在尝试使用 GET 参数从 HTTP 链接打开 XLS 文件。如果您只是将链接复制并粘贴到您的网络浏览器中,您将看到它有效。如果我省略 GET 参数,我可以使用 workbooks.open 打开工作簿,但它会打开错误的工作簿,因为您需要 GET 参数来准确提取我想要的内容。
Dim myURL As String
Dim winHttpReq As Object
Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")
myURL = "http://www.otcmarkets.com/common/ViewStockScreener.xls?otcMarketTier=&otcMarketTierDesc=&otcMarketTierGroup=&otcMarketTierId=&otcMarketTierGroupDesc=&allTierGroups=true&securityType=CORP&securityTypeDesc=Corporate%20Bond&countryId=&locale=&countryDesc=&localeDesc=&allLocales=true&sicIndustryIdentifier="
winHttpReq.Open "GET", myURL, False
winHttpReq.Send
MsgBox Len(winHttpReq.responseBody)
result = winHttpReq.responseBody
Dim x As Workbooks
Set x = result
x(1).Open
感谢您的帮助!
【问题讨论】: