Compartir a través de


VBA and Office Solutions in Visual Studio Compared

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

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

Comparison

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

VBA solutions

Office solutions in Visual Studio

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 VBA APIs.

Provides access to both 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.

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 Solutions and Office Solutions Created by Using Visual Studio

You can call VBA code from Office solutions created by using Visual Studio, and you can also call code in Office solutions created by using Visual Studio from VBA. The specific technique differs depending on whether your 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 Office Solutions and Combining VBA and Document-Level Customizations.

See Also

Concepts

Office Solutions Development Overview

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

Architecture of Document-Level Customizations

Architecture of Application-Level Add-Ins

Other Resources

Combining VBA and Document-Level Customizations

Securing Office Solutions

Getting Started (Office Development in Visual Studio)