Generating GUIDs from Visual Studio 2008

Tools > Create GUID tool is too cumbersome for this. I found a blog post that has a simple macro you can customize to bind a keyboard shortcut to paste in a new GUID Here are some full instructions, using their simple macro code:

  1. Tools > Macros > Macro Explorer (or hit ALT+F8)
  2. Right click Macros, choose New Macro Project…
  3. Choose a location for the Macro project and give it a meaningful name then click Add
  4. Rename Module1 to something more meaningful, then double-click to edit the module
  5. Insert the code to paste a new GUID into the current cursor position / selection: Public Sub PasteNewGuid() DTE.ActiveDocument.Selection.Text = "{" & System.Guid.NewGuid().ToString("D").ToUpper() & "}" End Sub
  6. Save the macro project and close the Macro IDE
  7. In Visual Studio: Tools > Options, select Environment > Keyboard
  8. Find the macro command you created (you can use the Show commands containing: to search on guid)
  9. Select the command in the list
  10. Ensure Use new shortcut in: has Global selected
  11. Place the cursor in Press shortcut keys: and hit the shortcut (ALT+G for me)
  12. Hit OK
  13. Test it out

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>