Excel add-in - Why must VBA project be compiled first??

Copper Contributor

I have written a VS solution that contains:
1) A C# project for an Excel document-level add-in. The project contains the XLSM file.

2) A Windows Installer project for installing the add-in

 

The XLSM file (included in the installation) contains some VBA macros written to interface with the C# side.

 

My problem arises once I install the add-in, open the XLSM file, and run a macro. The standard VBA error "Can't find project or library" pops-up. If I then go into the developer Visual Basic editor and compile the project (Debug > Compile VBAProject) no errors are reported. However, if I rerun the macro it works just fine.

 

What is going on here? Why does compiling the VBA fix enable the macros to work even though there were no errors to be found? And how can I include an XLSM in my Windows Installer project that works out of the box? Please help!

 

0 Replies