53.1. The Anatomy of a Macro

A Visual Studio macro (it's actually called VSMacro but is commonly known just as a macro among developers) is a stand-alone package of uncompiled code that can be run by the Visual Studio IDE to automate a task.

In fact, a macro is a piece of code and nothing else. Visual Studio has a specific extension for macro packages. A file with the .vsmacros extension is a macro package and is a known extension to Visual Studio.

A .vsmacros file can contain several components. One of these components is code modules. A code module can contain one or more macros, so you can include as many macros as you like in a .vsmacros file.

A macro itself is a public method in a module that takes no parameter and returns nothing and applies the Development Tools Extensibility (DTE) API to automate something in the IDE.

The nature of macros (which are code packages) makes their deployment a little difficult. You need to move and import the package in order to deploy a macro. This is covered later in the chapter.

You saw that a macro is a subroutine without parameters but can apply any object-oriented programming concept like class or enumeration types to get its job done. You can include other classes and modules to divide your code into smaller pieces and make your job easier.

When working with macros you don't have to deal with the same concepts like solutions and projects as you have to in the Visual Studio IDE. Instead, you have to deal with a Visual Studio macros system that works as a single root solution for all macros. This system includes your macro projects that are actually separate .vsmacros files. Each project consists of one or more modules, classes, and other programming material.

Moreover, you don't need to build and compile a macro project because a macro is a piece of code that Visual Studio runs on demand.

There is only one development language that you can use to write macro code and that is Visual Basic. Previously you had to use Visual Basic for Applications (VBA) to write a macro code for Visual Studio or Microsoft Office, but after the birth of .NET you can simply use Visual Basic to do this.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.97.53