title: Error in On Error statement
body: <p>I am totally not a VBScript developer. But as it usually happens I have to write a small script to check something. It opens Excel, writes something to it and closes it. But that's not the point. The point is that I cannot manage to write code for error handling. This script:</p>
  
  <pre><code>Sub Work()
  On Error GoTo ErrMyErrorHandler
  Dim objExcelApp
  Dim wb
  Dim ws
  
  Set objExcelApp = CreateObject("Excel.Application")
  Set wb = objExcelApp.Workbooks.Add(True)
  Set ws = wb.Sheets(1)
  
  ws.Cells(1,1).Value = "Hello"
  ws.Cells(1,2).Value = "World"
  
  wb.SaveAs("c:\test.xls")
  objExcelApp.Quit()
  Exit Sub
  
  ErrMyErrorHandler:
  MsgBox Err.Description, vbExclamation + vbOKCancel, "Error: " &amp; CStr(Err.Number)    
  End Sub
  
  Work()
  </code></pre>
  
  <p>gives this error:</p>
  
  <p><img src="https://i.stack.imgur.com/EJq4Q.png" alt="error"></p>
  
  <p>Line 2 is the line with the <code>On Error</code> statement. What am I doing wrong?</p>
  
  <p>Thank you.</p>