Hello,
I have a c# com object that exposes several methods.
This com object is to be used in vbscripts as well as vba scripts.
In my application error handling is done by throwing different types of custom exceptions. The problem is that when theses exceptions are caught by the vbscript the type of the exception is unknown.
Therefore I would need Err.Number to determine what kind of exception was thrown. Unfortunately I have not been able to figure out how that works.
For some reason ExternalExcepti on does not do the trick.
Simple example:
COM object:
VBScript:
I have been googeling for hours without any kind of success.
Kevin
I have a c# com object that exposes several methods.
This com object is to be used in vbscripts as well as vba scripts.
In my application error handling is done by throwing different types of custom exceptions. The problem is that when theses exceptions are caught by the vbscript the type of the exception is unknown.
Therefore I would need Err.Number to determine what kind of exception was thrown. Unfortunately I have not been able to figure out how that works.
For some reason ExternalExcepti on does not do the trick.
Simple example:
COM object:
Code:
[ComVisible(true)] public class MyClass { public void Test() { throw new MyTimeoutException() //MyTimeoutException somehow sets Err.Code to 123 } }
Code:
Dim k set k = CreateObject("ns.MyClass") on error resume next k.Test if err.number = 123 then MsgBox "Crap. Operation timed out." end if set k = nothing
Kevin
Comment