Dela via


VBA and Visual Studio Tools for Office Solutions Compared

Microsoft Visual Basic for Applications (VBA) uses unmanaged code that is tightly integrated with Office applications. Visual Studio Tools for Office solutions enable you to take advantage of the .NET Framework and Visual Studio design tools.

For information about the types of solutions you can create by using Visual Studio Tools for Office, see Office Solutions Development Overview.

Comparison

The following table provides a basic comparison between VBA and Visual Studio Tools for Office solutions.

Visual Basic for Applications

Visual Studio Tools for Office solutions

Uses code that is connected to and persisted with a specific document.

Uses code that is stored separately from the document (for document-level customizations), or in an assembly that is loaded by the application (for application-level add-ins).

Works with the Office object models and Visual Basic for Applications APIs.

Works with the Office object models and the .NET Framework APIs.

Designed for macro recording and a simplified developer experience.

Designed for security, easier code maintenance, and the ability to use the full Visual Studio integrated development environment (IDE).

Works well for solutions that benefit from a very tight integration with Office applications (IDE, menus, toolbar buttons, and so on).

Works well for solutions that benefit from the full resources of Visual Studio and the .NET Framework.

Has limitations for the enterprise, especially in the areas of security and deployment.

Designed for use in the enterprise.

Some things are still easier to do quickly using VBA. Specifically, you might want to continue using VBA for:

  • Custom worksheet functions.

  • Macro recording.

Combining VBA and Visual Studio Tools for Office Solutions

You can call VBA code from Visual Studio Tools for Office solutions, and you can also call code in Visual Studio Tools for Office solutions from VBA. The specific technique differs depending on whether your Visual Studio Tools for Office solution is an application-level add-in or a document-level customization. For more information, see Calling Code in Application-Level Add-ins from Other Solutions and Combining VBA and Document-Level Customizations.

See Also

Concepts

Office Solutions Development Overview

Calling Code in Application-Level Add-ins from Other Solutions

Combining VBA and Document-Level Customizations

Architecture of Document-Level Customizations

Architecture of Application-Level Add-Ins

Office Solutions Programming Model

Other Resources

Security in Office Solutions (2003 System)

Getting Started (Visual Studio Tools for Office)