Error Trapping from WSH

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
 
T

Tom Chau

Sorry all. The line "On Error Resume Next" in raiseError() should be
commented to illustrate the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top