urig

Tidbits from a .net life
posts - 89, comments - 22, trackbacks - 101

My Links

News



View Uri Goldstein's profile on LinkedIn

Add to Google

Twitter












Archives

Post Categories

Image Galleries

Blogs

Cool

How to enable programmatic access to VBA in Excel 2007

Just had my first encounter with VSTO, trying to embed a C# macro in an Excel workbook. I fired up the ol' Visual Studio 2005, created a new "Excel Workbook" project and bumped straight into this:

"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."

The problem with the above message? I didn't have any Word or Excel process running at all.

A quick google gave me the solution for Office 2003 (thanks go to Harry Miller - MSFT):

  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.
  4. Close all Office applications and try your project again.

But! I'm using Office 2007 beta. Where on earth is the Tools menu there? Yours truly spent well over 2 minutes digging through the menus and ribbons to give you the following instructions:

  1. Open Excel 2007.
  2. Click the Office Button (top-left most button in the window)
  3. Click the Excel Options button.
  4. Click Trust Center in the menu on the left.
  5. Click Trust Center Settings in the window on the right.
  6. In the new window that opens click Macros in the menu on the left.
  7. Check the box next to Trust Access to the VBA project object model.
  8. Click OK.
  9. Click OK.
  10. Close all Office applications and try your project again.

Works like a charm, as long as you accept the security implications of allowing Excel and Word programmatic access to the "Microsoft Office Visual Basic for Applications project system" mentioned above.

Print | posted on Monday, January 15, 2007 8:50 AM |

Feedback

Gravatar

# Programmatic access to the Microsoft Office Visual Basic for Applications project system could not be enabled.

In Darwin i wanted to show off VSTO in Visual Studio 2005. So the night before I fire up Visual Studio
2/21/2007 4:17 AM | Ozzie Rules Blogging
Gravatar

# re: How to enable programmatic access to VBA in Excel 2007

Do you have to use/have VSTO to use/run VBAs? We have these worksheets that came with a textbook and it says that a VBA component is not installed. I've done what you did and many other things and it still won't work. Got any ideas? Thanks.
1/22/2008 10:30 AM | Joey
Gravatar

# re: How to enable programmatic access to VBA in Excel 2007

Thanks very much - solved my problem
3/25/2008 6:20 AM | Garry

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 8 and 8 and type the answer here:

Powered by: