我正在尝试使用QueryTables从本地服务器Web链接中抓取数据,我每分钟重复一次该功能以跟踪该链接上的数据。然而。有时,链接会断开1-2分钟,在此期间,如果Excel尝试提取数据,它将永远冻结。 反之,如果链接没有响应,是否有将IF条件设置为Exit Sub的条件?
这是我的代码:
Sheets("Sheet1").Cells.Clear
Sheets("Sheet1").Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;https://linkylink.com", Destination:= _
Range("$A$1"))
.Name = "linkylink"
.WebFormatting = xlNone
.WebSelectionType = xlSpecifiedTables
.WebTables = "1"
.Refresh BackgroundQuery:=True
End With