I keep getting Run-time error '1004': Application-defined or object-defined error as I'm trying to pull this information from the web through VBA. I'm at my wits end because I can't find any errors that I might have made in this and I'm thinking it some sort of permissions issue. I'm running it on Excel 2016 on Windows. Thank you in advance.
Option Explicit
Sub QueryStarter()
Dim url As String
url = "https://www.xe.com/currencytables/?from=USD&date=2021-01-23"
ThisWorkbook.Worksheets("SFI").Activate
With ActiveSheet.QueryTables.Add(Connection:=url, Destination:=Worksheets("SFI").Range("A1")) 'this is where 1004 pops up
.Name = "My Query"
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebTables = "historicalRateTbl"
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
question from:
https://stackoverflow.com/questions/65866293/querytables-add-1004-issue-for-pulling-from-the-web 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…