通过VBScript和QueryTable连接互联网时出错

时间:2019-05-14 14:04:59

标签: vbscript

我想使用VBScript(与VBA中的QueryTables connectino方法相同的过程)将网站上的一些数据捕获到Excel文件中。 但是,当我尝试执行脚本时发生错误。 错误状态为“互联网连接错误”和“无法连接到Internet服务器”

Dim oExcel
Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = true
oExcel.DisplayAlerts = true
Dim oBook, Connection
Set oBook = oExcel.Workbooks.Add()
Set oSheet = oBook.Worksheets(1)
Connection = "URL; https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange"

With oSheet.QueryTables.Add(Connection, oExcel.ActiveCell)
        .Name = "exchange"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .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

0 个答案:

没有答案