Inserting GUID directly into the code

I have always used guidgen.exe to generate GUID. It comes directly with VS and it is available out of the box. This tool generates the GUID in four different formats, unfortunately all of them contain some extra characters, plus you have to copy & paste it to your code and clean it up.

Torben suggested this VS macro, which actually inserts a clean, capitalized GUID directly where you need it. Simple and convenient.

Sub InsertGuid()

Dim textSelection As TextSelection

textSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection)

textSelection.Text = System.Guid.NewGuid.ToString().ToUpper()

End Sub

One more little improvement to my all precious development VM environment.