Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blackskye-sx/31a09b10e81d26ee6c49e88d7a3456e8 to your computer and use it in GitHub Desktop.
Save blackskye-sx/31a09b10e81d26ee6c49e88d7a3456e8 to your computer and use it in GitHub Desktop.
Generate a GUID from VBA or VBScript
Function GenGuid() As String
Dim TypeLib As Object
Dim guid As String
Dim guid2 As String
Set TypeLib = CreateObject("Scriptlet.TypeLib")
guid = Left$(TypeLib.guid, 38)
Set TypeLib = Nothing
' format is {24DD18D4-C902-497F-A64B-28B2FA741661}
guid = Replace(guid, "{", "")
guid = Replace(guid, "}", "")
'Guid = Replace(Guid, "-", "")
'Return result
GenGuid = guid
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment