Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. On Error GoTo error_handler
  2. Workbooks.Open Filename:=("http://chart.finance.yahoo.com/table.csv?s=FAN.L&a=2&b=04&c=2014&d=2&e=21&f=2014&g=d&ignore=.csv")
  3.  
  4. On Error Resume Next
  5. Workbooks.Open Filename:=("http://chart.finance.yahoo.com/table.csv?s=FAN.L&a=2&b=04&c=2014&d=2&e=21&f=2014&g=d&ignore=.csv")
  6. On Error GoTo error_handler
  7.  
  8. If Dir(MyFileName) <> "" Then
  9. Workbooks.Open Filename:="C:123.xls"
  10. Else
  11. MsgBox "Spreadsheet could not be found in C:", vbCritical + vbOKOnly, "File not found"
  12. End If
  13.  
  14. Public Sub ErrorHandlingExample()
  15.  
  16. On Error GoTo ErrorHandlingExample_Error
  17.  
  18. Debug.Print 5 / 0
  19.  
  20. On Error GoTo 0
  21. Debug.Print "No error"
  22.  
  23. Exit Sub
  24.  
  25. ErrorHandlingExample_Error:
  26.  
  27. Debug.Print "Error was found - " & Err.Description
  28.  
  29. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement