Combining VBA and Managed Code Extensions
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Combining VBA and Managed Code Extensions

Note Required applications

The features in this topic are available only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005


    Visual Studio Team System

  • Microsoft Office 2003

It is not recommended that you use Visual Basic for Applications (VBA) code in document-level customizations for Microsoft Office Word or Microsoft Office Excel. If your solution requires it, however, you can use both types of code in a single project.

Design Time

When you open your project in Visual Studio, the document is opened in design mode. VBA code does not run when the document is in design mode, so you can work on the document and managed code extensions without triggering the VBA event handlers.

Run Time

When you run the solution, event handlers in both VBA and the managed code extensions pick up events that are raised in the document, and both sets of code run. You cannot determine beforehand which code will run before the other; you must determine this through testing in each individual case. You can get unexpected results if the two sets of code are not carefully coordinated and tested.

See Also

© 2015 Microsoft