COM exceptions

The COM integrations you write may encounter errors (exceptions) as they run. Use the exception handling capability in Dexterity to deal with COM exceptions that occur. To learn more about exception handling, refer to Structured Exception Handler.

Whenever a COM exception occurs in sanScript code, a system exception is thrown. The constant EXCEPTION_CLASS_OBJECT_EXCEPTION represents any COM exception thrown by Dexterity. The exception subclass, returned by the Exception_SubClass() function, indicates the actual COM exception that occurred.

To find what COM exception occurred, scroll down in the error dialog that displays the COM exception. The exception subclass will be listed, and indicates the error that occurred.


The following example attempts to minimize the active document in Microsoft Word. If there isn’t an active document, a COM exception is thrown indicating the action can’t be performed. The code catches the COM exception (-2146824040), and displays an appropriate message.

local Word.Application app;
local Word.Window active_win;
local long exception_subclass;

{Retrieve a reference to Word}
app = COM_GetObject("Word.Application");

{Minimize the active window}
	active_win = app.ActiveWindow;
	active_win.WindowState = Word.wdWindowStateMinimize;
	{Find out what the subclass of the exception is}
	exception_subclass = Exception_SubClass();

	if exception_subclass = -2146824040 then
		warning "No document is open.";
	end if;
end try;

Documentation Feedback