標題:
[發問]
如何略過網頁的錯誤訊息?
[打印本頁]
作者:
PKKO
時間:
2016-10-7 12:09
標題:
如何略過網頁的錯誤訊息?
下列模組因為網址錯誤,會產生出網頁的錯誤訊息,要如何略過網頁的錯誤訊息呢?
Function test()
On Error Resume Next '即便錯誤繼續也會出現錯誤訊息
ayear = 2016 '從2016開始
stockid = "6244.tw"
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;http://ichart.finance.yahoo.com/table.csv?s=" & stockid & "&a=00&b=4&c=" & ayear & "&d=" & Month(Date) & "&e=" & Day(Date) & "&f=" & Year(Date) & "&g=d&ignore=.csv" _
, Destination:=Range("A1"))
.Name = "stockprice"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 950
.TextFileStartRow = 2
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False '這個地方只要網址錯誤就會出現錯誤訊息,如何錯誤之後略過錯誤訊息?
End With
End Function
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)