Board logo

標題: [發問] 如何略過網頁的錯誤訊息? [打印本頁]

作者: PKKO    時間: 2016-10-7 12:09     標題: 如何略過網頁的錯誤訊息?

下列模組因為網址錯誤,會產生出網頁的錯誤訊息,要如何略過網頁的錯誤訊息呢?
  1. Function test()

  2. On Error Resume Next '即便錯誤繼續也會出現錯誤訊息
  3. ayear = 2016 '從2016開始
  4. stockid = "6244.tw"
  5. With ActiveSheet.QueryTables.Add(Connection:= _
  6.     "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" _
  7.     , Destination:=Range("A1"))
  8.     .Name = "stockprice"
  9.     .FieldNames = True
  10.     .RowNumbers = False
  11.     .FillAdjacentFormulas = False
  12.     .PreserveFormatting = True
  13.     .RefreshOnFileOpen = False
  14.     .RefreshStyle = xlOverwriteCells
  15.     .SavePassword = False
  16.     .SaveData = True
  17.     .AdjustColumnWidth = True
  18.     .RefreshPeriod = 0
  19.     .TextFilePromptOnRefresh = False
  20.     .TextFilePlatform = 950
  21.     .TextFileStartRow = 2
  22.     .TextFileParseType = xlDelimited
  23.     .TextFileTextQualifier = xlTextQualifierDoubleQuote
  24.     .TextFileConsecutiveDelimiter = False
  25.     .TextFileTabDelimiter = True
  26.     .TextFileSemicolonDelimiter = False
  27.     .TextFileCommaDelimiter = True
  28.     .TextFileSpaceDelimiter = False
  29.     .TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1)
  30.     .TextFileTrailingMinusNumbers = True
  31.     .Refresh BackgroundQuery:=False '這個地方只要網址錯誤就會出現錯誤訊息,如何錯誤之後略過錯誤訊息?
  32. End With

  33. End Function
複製代碼





歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)