Link to home
Create AccountLog in
Avatar of HugoHiasl

asked on

Add-In Express Exception when accessing Excel VBProject property


I created an Add-In for Excel with Add-In Express. It is in the Workbook_Open event and works fine with nearly all workbooks.

But I have one workbook with macros in it that pops up with a security warning when I open it because it is not a trusted location. Normally I click "Enable Macros".

When I do this after installing the Add-In it throws an exception in the first of the following rows.

                bool test1 = (ExcelApp.ActiveWorkbook.VBProject != null);
                bool test2 = (ExcelApp.ActiveWorkbook.VBProject.Protection == Microsoft.Vbe.Interop.vbext_ProjectProtection.vbext_pp_none);
                bool test3 = (ExcelApp.ActiveWorkbook.VBProject.VBComponents != null);

                // check if there are components to keep safe from exceptions
                if ((ExcelApp.ActiveWorkbook.VBProject != null) && (ExcelApp.ActiveWorkbook.VBProject.Protection == Microsoft.Vbe.Interop.vbext_ProjectProtection.vbext_pp_none) && (ExcelApp.ActiveWorkbook.VBProject.VBComponents != null)) {

Open in new window

the three bool variables were only introduced to break down the error because it first appeared in the if-condition which consists of three conditions.

The error is:
"Exception from HRESULT: 0x800A03EC"

Does anyone know where the problem is?

Thanks in advance
Avatar of Mihai Stancescu
Mihai Stancescu
Flag of Romania image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of HugoHiasl


Did not solve it but pointed me to a right direction...