刷新查詢的最佳方式是設置.Refresh BackgroundQuery := False
。刷新應該刷新結果。你也可以設置.RefreshPeriod = 0
。
Sub webquery()
Dim url As String
url = "URL;http://test.com"
With Worksheets("Sheet1").QueryTables.Add(Connection:=url, Destination:=Worksheets("Sheet1").Range("A1"))
.Name = "Geocoder Query"
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.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
End Sub
@nightTrevors如果此答案有幫助,請點擊旁邊的複選框將其接受。 閱讀更多[here](http://stackoverflow.com/about) – Santosh