Skip to content


Fast generation of Guid in Visual Studio (2005 and 2008)

I have had trouble with my Visual Studio not having GuidGen to create a Guid a few times. This bothered me a lot, and I didn’t want to go to a webpage to create a new Guid, and also didn’t want to do it through code.
So I found a solution to that. This is how you via a shortcut can create a Guid right at your cursor in Visual Studio. Quite nifty. I use this a lot in SharePoint development, especially when creating fields, content types etc. in CAML.

1: Open up Visual Studio. Goto Tools -> Macros -> Macro Explorer. Can also be accessed with Alt+F8.

2: Right-click “Macros” and choose “New Macro Project”.

3: Give it a name, and then rename “Module1″.

4: Doubleclick the module and copy paste this code in there and save the macro.

Sub Create_GUID()
        DTE.ActiveDocument.Selection.Text = System.Guid.NewGuid().ToString("D").ToUpper()
End Sub

The code goes just before “end module”.

5: Choose Tools -> Options and choose “Keyboard” under “Environment”.

6: In the “Show Commands Containing” textbox, you can find the module by entering “Create_guid”.

7: Press down your wanted shortcut in the “Press shortcut keys” textbox and then click “Assign”.

You can now press your chosen shortcut and a new Guid will appear right at your cursor. This not only makes you able to live without GuidGen, it’s a lot faster too!

Recommended reading

These book will help you tremendiously as a developer using Visual Studio 2008, if you are a .NET or a SharePoint programmer or not. Stop doing everything the hard way, and learn the ins and out of Visual Studio 2008.

DeliciousDiggTwitterFacebookLinkedInTechNetStumbleUponNewsVineTechnorati FavoritesSlashdotMSDNShare

Related posts:

  1. Visual Studio 2008 text file encoding problems
  2. Enable intellisense in Visual Studio for SharePoint / WSS xml files

Posted in Visual Studio.


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.



Page optimized by WP Minify WordPress Plugin