从Internet导入表失败(Mac)

基本上我有下面的代码,我使用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 

此外,我想问如何Import from web在Mac Excel 2011中Import from web ,因为我找不到这样的图标。 请帮助我,因为我在这里很迷路。

这个网站说(见列表中的数字9) PreserveFormatting不存在于Mac和RefreshPeriod可能会不同…

删除这两个语句可能会解决您的问题。

我唯一的build议是删除内嵌评论,因为它可能是问题的一部分。 这里是关于如何在Mac上创buildnetworking查询的类似问题的链接 。

从我可以从几个Google查询中得到的结果来看,Excel 2011 Mac中的VBA与PC上的VBA几乎完全相同,所以应该没有问题。 我经常推荐几个论坛来介绍这个网站 ,了解这些差异依然存在。