T
Tom Chau
Hi all,
I encountered a great difficulties in Automation with error handling
and hope to seek helps from all of you:
1) A Excel workbook is created to include a module contain the
following sub which raise an error:
Const MY_ERROR As Long = 4567
Public Sub raiseError()
On Error Resume Next
Err.Raise MY_ERROR, , "This is my error."
End Sub
2) Another WScript is used to invoke that function using
Excel.Application:
Public Sub abc()
On Error Resume Next
Dim xl
Set xl = CreateObject("Excel.Application")
xl.Visible = True
Dim file
file = Join(Array(WScript.ScriptFullName, "..", "MyExcel.xls"), "\")
xl.Workbooks.Open file
xl.Run "raiseError"
If Err.Number <> 0 Then
Msgbox Err.Description
End If
xl.Quit
End Sub
However, the above example fails to trap the errors occured in the
Excel.
Could anyone would have experience to resolve it issues?
Thanks a lot.
Tom
I encountered a great difficulties in Automation with error handling
and hope to seek helps from all of you:
1) A Excel workbook is created to include a module contain the
following sub which raise an error:
Const MY_ERROR As Long = 4567
Public Sub raiseError()
On Error Resume Next
Err.Raise MY_ERROR, , "This is my error."
End Sub
2) Another WScript is used to invoke that function using
Excel.Application:
Public Sub abc()
On Error Resume Next
Dim xl
Set xl = CreateObject("Excel.Application")
xl.Visible = True
Dim file
file = Join(Array(WScript.ScriptFullName, "..", "MyExcel.xls"), "\")
xl.Workbooks.Open file
xl.Run "raiseError"
If Err.Number <> 0 Then
Msgbox Err.Description
End If
xl.Quit
End Sub
However, the above example fails to trap the errors occured in the
Excel.
Could anyone would have experience to resolve it issues?
Thanks a lot.
Tom