Created
March 23, 2015 00:21
-
-
Save joehanna/4eaa64d8e34e9d8e2646 to your computer and use it in GitHub Desktop.
Generate a GUID from VBA or VBScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
As of Office Security updates - July 2017 - this is likely to give a permission denied error. An alternative method is given in this Stack Overflow question.