Tuesday 17 March 2009

Insert GUID VBScript Code


I've recently been playing around with Wix and it involves a lot of GUID (Global Unique Identifier) creation. You can assign the following VBScript to a macro key press or toolbar button in visual studio (Menu: Tools > Macros).

Sub InsertGuid()
  Dim objTextSelection As TextSelection
  objTextSelection = CType(DTE.ActiveDocument.Selection(), EnvDTE.TextSelection)
  objTextSelection.Text = System.Guid.NewGuid.ToString.ToUpper(New System.Globalization.CultureInfo("en", False))
End Sub


The following link contains detail on how to assign it to a keypress or a toolbar button.

Assigning VBScript Macros to Toolbar Buttons or Key Sequences

No comments: