In Darwin i wanted to show off VSTO in Visual Studio 2005. So the night before I fire up Visual Studio and do the normal File>New Project>Office>Excel Work book. And I get the error:
“A compatible version of Microsoft Office Excel 2003 is not installed on this computer. ….”
Fair enough, I didn’t have ANY Office 2003 installed (only Office 2007 which shipped well after VST0 2005) So installed Office 2003 (and sp2) and try it again and it works –yeah.
The next day I go to demo VSTO -doing the EXACT same thing but this time I get the error:
"Programmatic access to the Microsoft Office Visual Basic for Applications project system could not be enabled. If Microsoft Office Word or Microsoft Excel is running, it can prevent programmatic access from being enabled. Exit Word or Excel before opening or creating your project."
Grrr! Doing a search coughed up Harry’s post:
If you have VBA, see if you can manually enable programmatic access to the VBA project system. Do do that, open Word or Excel. Then:
1. On the Tools menu, point to Macro, and then click Security.
2. Click the Trusted Publishers tab.
3. Select the check box next to Trust access to Visual Basic Project, and then click OK.
Close all Office applications and try your project again.
Except that 2003 already had the checkbox for “Trust access to Visual Basic” double Grr!
After some more searching I tried Uri’s suggestion of Enabling Visual Basic in Excel 2007 (steps below) –and this worked! Interestingly now in the Visual Studio IDE Excel 2007 is displayed (hence the error) but at run time Excel 2003 is loaded!
- Open Excel 2007.
- Click the Office Button (top-left most button in the window)
- Click the Excel Options button.
- Click Trust Center in the menu on the left.
- Click Trust Center Settings in the window on the right.
- In the new window that opens click Macros in the menu on the left.
- Check the box next to Trust Access to the
- VBA project object model.
- Click OK.
- Click OK.
- Close all Office applications and try your project again.