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:
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: " & CStr(Err.Number)
End Sub
Work()
gives this error:

Line 2 is the line with the On Error statement. What am I doing wrong?
Thank you.
looks like you can not point custom label to error handler in VB Script. You can only use
if you use the second syntax, you can catch occurring exceptions via Err global variable: