我需要编写一个从以下url导入数据的宏: www.gfigroup.com/docs/sef/marketdata/2014-04-08_daily_trade_data.xls。 如果您将其复制并粘贴到浏览器中,则会导入xls文件。 我使用的代码如下:
Dim wbMe As Workbook
Dim wsNew As Worksheet
Dim w As Integer
Dim wbURL As Workbook
Dim url As String
Set wbMe = ThisWorkbook
url = "www.gfigroup.com/docs/sef/marketdata/2014-04-08_daily_trade_data.xls"
Set wbURL = Workbooks.Open(url)
'## Add code to copy this data to your workbook and/or manipulate the data...'
w = wbMe.Sheets.Count
'## Add a new worksheet to the end of ThisWorkbook:'
Set wsNew = wbMe.Sheets.Add(After:=wbMe.Sheets(w))
'## Copy & Paste this data in to our new worksheet:'
wbURL.Sheets(1).Cells.Copy Destination:=wsNew.Range("A2")
'## Close the downloaded version which we no longer need:'
wbURL.Close
但是,当我运行它时,'我有这个运行时错误' 1004'说它无法找到资源,并询问它是否已被删除或重命名。 有人已经遇到过这个问题吗?并最终找到了解决方案。
谢谢。
答案 0 :(得分:1)
您应该将http://
添加到网址的开头,它应该有效..
url = "http://www.gfigroup.com/docs/sef/marketdata/2014-04-08_daily_trade_data.xls"