|
想请教一下:我用WEB取数,以下代码在总数量不多的时候运行还算正常,一但超过40以上就会卡死,出现以下错误代码:运行时错误-2147417848 80010108 方法Refresh作用于对象Querytable时失效,请问这是什么原因造成的呀?
Option Explicit
Sub NTPS²éѯ()
Dim intnum As Integer
Dim i, m, p, q As Integer
Dim strdaima As String
Dim strhaoma As String
Application.ScreenUpdating = False '¹Ø±ÕÆÁĻˢÐÂ
intnum = Application.WorksheetFunction.CountA([A:A]) - 1
For i = 1 To intnum
Cells(2, 2).Value = "ÕýÔÚ²éѯµÚ" & i & "ÕÅ"
Application.ScreenUpdating = False
strdaima = Cells(i + 1, 1).Value
Sheet2.Cells.ClearContents
With Sheet2.QueryTables.Add(Connection:= _
"URL;http://npts2.apis.dhl.com:6010/npts/ShipmentDataFetchServlet?action=14&querycriteria=QUERY_BY_AWB&duplicatedCheckpoints=yes&queryData=" & strdaima, _
Destination:=Sheet2.Range("$A$1"))
.Name = "µÚ" & i & "ÕÅ"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "1,2,3,4,5,6,7,8,9,10,11,12"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
|
|