Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel查询表格式不正确_Excel_Vba - Fatal编程技术网

Excel查询表格式不正确

Excel查询表格式不正确,excel,vba,Excel,Vba,我有一些VBA代码,已经运行了好几年了。代码是: With ActiveSheet.QueryTables.Add(Connection:="URL;" & myURL, Destination:=Range("$A$1")) .Name = "Weather" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = Tru

我有一些VBA代码,已经运行了好几年了。代码是:

With ActiveSheet.QueryTables.Add(Connection:="URL;" & myURL, Destination:=Range("$A$1"))
    .Name = "Weather"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .BackgroundQuery = True
    .RefreshStyle = xlOverwriteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .WebSelectionType = xlEntirePage
    .WebFormatting = xlWebFormattingNone
    .WebPreFormattedTextToColumns = True
    .WebConsecutiveDelimitersAsOne = True
    .WebSingleBlockTextImport = False
    .WebDisableDateRecognition = False
    .WebDisableRedirections = False
    .Refresh BackgroundQuery:=False
End With
其中myURL是:

用于返回逗号删除文件的代码,我可以解析该文件以获取所需数据。然而,在过去的几天里,代码返回一个完全格式化的网站。网站似乎无法识别“&format=1”(需要返回逗号分隔的文件)


当我直接在Chrome或IE中输入URL时,我会收到以逗号分隔的文件。我的查询表(不再)走运了。有人能给我一些指导吗?

当我点击链接时,它会将我带到一个类似CSV的文件。你是否考虑过Web请求来拉动数据?这是我的问题。当我在Chrome中打开URL时,我会得到CSV类型的文件。这就是我想要的。但是,当我使用上面的VBA代码进行web查询时(这与web请求相同吗?),我不会得到相同的CSV类型文件。相反,我在目的地工作表中获取普通网站的内容。