作者skyivan (官人)
看板Office
标题[问题] VBA撷取网路上xls档的资料出错
时间Tue Aug 16 09:54:47 2016
软体:excel
版本:2010
我想试着抓msci台湾指数的权重表直接汇入excel
https://www.msci.com/eqb/custom_indexes/tw_performance.xls
过去使用的程式码如下,抓网页跟csv都可以用,但这次抓xls不行
会在.Refresh BackgroundQuery:=False 这里显示"不正确的web查询"
请问高手们该如何解决?
Sub test()
Set DataSheet = ActiveSheet
Range("A1").CurrentRegion.ClearContents
qurl = "网址"
QueryQuote:
With ActiveSheet.QueryTables.Add(Connection:="URL;" & qurl,
Destination:=DataSheet.Range("A1"))
.AdjustColumnWidth = False
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With
End Sub
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 123.51.219.89
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Office/M.1471312491.A.C9F.html
1F:→ soyoso: 用workbooks.add 接网址,试试 08/16 10:06
2F:→ soyoso: 如要用唯读的话 workbooks.open 接网址 08/16 10:09
3F:→ skyivan: 已解决!原来这样就行了,非常感谢 08/16 10:15