"Command Failed" - when a Word dialog is cancelled

Add-in Express™ Support Service
That's what is more important than anything else

"Command Failed" - when a Word dialog is cancelled
Exception generated when a Convert document dialog is cancelled 
Sharad Patel




Posts: 30
Joined: 2008-04-17
I have an add-in that uses some code to open a Word document. Normally this works well enough except if I try to open a non-Word document, Word shows me the convert dialog, if I cancel this dialog I get an error that is not being trapped by my try..catch block - here is the code


            Word.Documents documents = app.Documents;
            Word.Document document = null;
            try
            {
                document = documents.Open(ref file, ref confirmConv, ref oReadOnly, ref addToMRU, ref a1, ref a2, ref a3, ref a4, ref a5, ref a6, ref a7, ref visible);
            }
            finally
            {
                if (document != null)
                {
                    Marshal.ReleaseComObject(document);
                }
                if (documents != null)
                {
                    Marshal.ReleaseComObject(documents);
                }
            }



Despite the try block, I still get the error window generated by Add-In Express - is there a way to trap this error?

Thanks.
Posted 18 Apr, 2008 09:43:31 Top
Sergey Grischenko


Add-in Express team


Posts: 6954
Joined: 2004-07-05
Hi Sharad.

I don't see the 'catch' statement in your code.
Posted 19 Apr, 2008 15:01:03 Top