The VBScript Network and Systems Administrator's Cafe

Feb 13 2009   6:40PM GMT

Creating a unique GUID for use in your VBScripts

Jerry Lees Jerry Lees Profile: Jerry Lees

Today I answered a question in the ITKE unanswered questions for Word VBA on how to be certain a filename was unique across several users using it. The answer I gave answered the question, but I knew there was a way to create GUID’s within VBScript but couldn’t recall how.

GUID’s are cryptic to look at, but they are pretty much guaranteed to be unique. After some research I found the library that provides this functionality… Scriptlet.TypeLib! Below is a short script that gives you an idea of how to use it in your scripts to generate unique strings for when you need a guaranteed unique name or identifier.

Option Explicit

Dim GUID
Set TypeLib = CreateObject(“Scriptlet.TypeLib”)
GUID = TypeLib.Guid

Enjoy!

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: