基本上我有以下代码,我使用Excel 2010在PC桌面上制作。它工作得很好。但是,当我将文件传输到Mac并使用Excel 2011执行getStockDataTest()
子例程时,它失败了。
我不断收到此错误消息
Option Explicit
Sub getStockDataTest()
getGoogleStockHistory 700
End Sub
Sub getGoogleStockHistory(gInt As Long)
'
' Macro1 Macro
'load google stock hisotry
'
'.add -> create object
'With ActiveSheet.QueryTables.Add(Connection:= _
'"URL;https://www.google.com.hk/finance/historical?q=HKG%3A000&ei=V5k-U4CjHtDakQWfQw#" _
, Destination:=Range("$A$1"))
With ThisWorkbook.Sheets("Query").QueryTables(1)
.Connection = "URL;https://www.google.com.hk/finance/historical?q=HKG%3A" & Format(gInt, "0000") & "&num=200" '&num 200 = 200 days of data
.Name = "WebQuery"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables 'xlEntirePage will get entire webpage
.WebTables = "4"
.WebFormatting = xlWebFormattingNone
.WebDisableDateRecognition = False
.Refresh BackgroundQuery:=False
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableRedirections = False
End With
Range("A1").Select
End Sub
此外,我想问一下如何在Mac Excel 2011中执行Import from web
,因为我找不到这样的图标。请帮帮我,因为我在这里很丢失。