Forum Discussion
Eugene Cloud
Aug 06, 2017Copper Contributor
Query hangup
Occasionally my macro hangs. I believe it is in this code but since the only way to spot the hang is to task manager kill the job, I can't be sure. Is there a way to return to my code after a time out period attempting to access a web-page? The query routine was recorded from a forum so my understanding of it is incomplete. Thank you for any suggestions.
Sub QueryRec(urll, nn, wbfor)
'
' QueryRec Macro
' Recording of a web query
'
'
With ActiveSheet.QueryTables.Add(Connection:= _
urll, Destination:=Range( _
"[scrapeWebPage.xlsm]Sheet1!$A$10"))
.Name = nn
.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 = wbfor
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
- You may want to try changing .BackgroundQuery = True to .BackgroundQuery = False