Sub 下載基本資料()
.
.
.
更新資料 a '執行12檔案更新
If bStop Then Exit For
.
.
.
End Sub
Sub 更新資料(a)
Dim Sh As Worksheet, MyURL$, MyQy As QueryTable
Dim iI%, lJ&, OpenForms
.
.
.
On Error GoTo errGet
.Refresh '更新
On Error GoTo 0
End With
End If
End With
Next
End With
fs = Dir()
Loop
End With
Exit Sub
: errGet
If Err.Number = 1004 Then
For lJ = 1 To 5000 ' 讀取網頁失敗時, 等一段時間再重讀一次, 若連續5次失敗,則中止讀取.
If lJ Mod 1000 = 0 Then OpenForms = DoEvents ' 每隔一段時間將控制權還給Windows處理其他程式的作業.
Next
iI = iI + 1
If iI > 10 Then
bStop = True
MsgBox "讀取網頁失敗, 程式終止..."
Exit Sub
End If
Resume
Else
Resume Next
End If
End Sub作者: spermbank 時間: 2013-11-17 01:20