BT

InfoQ Homepage News Macros Return to Visual Studio

Macros Return to Visual Studio

Bookmarks

Several years ago (Visual Studio 2010 era), Visual Studio included a very popular macro system built around the VBA Macro language.  Starting with VS2012, that functionality has been missing from Visual Studio leaving users to either do without or seek a 3rd party alternative.  To address this shortcoming, Microsoft’s Justin Clareburt has announced the return of macros to both Visual Studio 2013 and 2015 via a new extension called Macros for Visual Studio. 

The extension provides users with several abilities, including the option to record and replay active document operations and IDE commands.  Macros can be replayed multiple times, they can be assigned keyboard shortcuts, and the resulting macro files can be edited from within Visual Studio.  The extension also can make use of Visual Studio DTE APIs for greater manipulation of the IDE beyond just recording keystrokes.

This access to the DTE APIs provides a major source of power for this extension.  Sample scripts are provided that include demonstrations on how to programmatically adjust font sizes, set breakpoints, or modify all files in active solution among many others.

It should be noted that there are a few limitations in the current extension.  First and perhaps most serious, developers who may have VS2010-era macros still in their possession will find that they are not usable with this extension as the macros are now written in JavaScript.  Another limitation is that it cannot record user input given to dialog boxes from within Visual Studio.  Third, macros cannot call other macros.  Finally, macros do not have not have a concept of asynchronous events (such as the variable time it may take for a build to complete) and so attempting to script around such events may lead to undefined behavior.

The extension itself is written in C#, licensed under the MIT license, and available on GitHub for those who wish to examine how it works.  It is also available via the Visual Studio Gallery for immediate installation and use within your IDE.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

  • Small mistake in article

    by Kyle Smith /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    ...Visual Studio 2013 and 2013 via...
    should be
    ...Visual Studio 2013 and 2015 via...

  • Re: Small mistake in article

    by Charles Humble /

    Your message is awaiting moderation. Thank you for participating in the discussion.

    Thanks for highlighting this. Fixed.

    Charles Humble
    Head of editorial, InfoQ.com

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.