Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8619649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:23:28+00:00 2026-06-12T06:23:28+00:00

Is it possible to create a code snippet or something similar to automate the

  • 0

Is it possible to create a code snippet or something similar to automate the process of generating and inserting GUIDs in to the text editor in Visual Studio 2012?
I frequently need to generate new GUIDs (WiX installer for example, as well as our own internal framework).

I used to use a macro to perform this job, creating a new GUID and then inserting it in to the current ActiveDocument. I would the bind the macro to Shift-Ctrl G so I could rapidly insert a new ID without having to launch the Create Guid tool and copy from there.

Macro functionality has now been removed from Visual Studio 2012 so I need an alternative method, I would assume that it is possible to do with an Extension but I am unfamiliar with developing extensions and that approach would seem a little heavy handed!

Any suggestions would be appreciated, failing that then a pointer at any information on what sort of extension would be required to interact with the text window and insert text would be appreciated. I could then make an extension and post it on the Visual Studio Gallery.

Thanks,
Anthony

Edit to add – whatever solution is proposed would need to be “triggerable” from a keyboard shortcut. As I stated above, I tied the macro to Ctrl Shift G because it was easy to remember and press while writing code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:23:29+00:00Added an answer on June 12, 2026 at 6:23 am

    You could write a Visual Studio 2012 extension to accomplish this!
    If you’ve never written an Add-in before, this is a simple one to get you started!

    Here are the steps to create this type of add-in:

    1. Create a New Project in Visual Studio 2012
    2. Choose Templates -> Other Project Types -> Extensibility -> Visual Studio Add-in
    3. Name your project, click OK.
    4. Follow the Add-in wizard steps. When prompted, check the box for: “Yes, create a ‘Tools’ menu item.” Optionally, I also check “My Add-in will never put up modal UI…”
    5. Finish the wizard and implement the follow code in Exec(…)

      public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
      {
          handled = false;
          if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
          {
              if (commandName == this.GetType().Namespace + ".Connect." + this.GetType().Namespace)
              {
                  if (_applicationObject.ActiveDocument != null)
                  {
                      TextSelection objSel = (EnvDTE.TextSelection)(_applicationObject.ActiveDocument.Selection);
      
                      objSel.Insert(Guid.NewGuid().ToString());
                  }
      
                  handled = true;
                  return;
              }
          }
      }
      
    6. Build the project, and deploy AddInName.dll, AddInName.AddIn, and AddInName.xml to c:\users\username\documents\Visual Studio 2012\Addins. [If the Addins folder doesn’t exist, create it]

    7. In Visual Studio 2012, under Tools -> Addin Manager, Check the box on the left next to AddInName.
    8. Restart Visual Studio 2012
    9. You should now see the AddInName listed under Tools. [probably with a Smiley face!]
    10. When you click on this, it should insert a new GUID at your cursor’s location.
    11. Map this to a hotkey by navigating to Tools -> Options -> Environment -> Keyboard, search for AddInName, and bind a hotkey to it.

    Voila! Hotkey GUID generation and a little bit of Visual Studio Add-in know how. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know its possible to create activities by doing something like the code bellow,
Is possible create an extension for SQL Management Studio in Visual Studio 2010? Visual
Hi I would like to create a Visual Studio snippet that I can have
Is it possible to create a Line in XAML (without any C# code behind)
When using Entity Framework Code First 4.3.1 it is possible to create relationships with
Is it possible to maintain app lifecycle with my code. I mean to create
Is it possible to write code template or a snippet which will do following:
In Visual Studio you can use code snippets e.g. when your are editing a
Hi it'd like to know if it's at all possible create a parametric equalizer
Possible Duplicate: Create provisioning profile in iphone application i developed my iphone app and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.