Possible to generate a GUID in Excel?

D

Dan

Is there an easy way to create a GUID in Excel? (Is there a Microsoft
library I can call, or do I have to write my own?)

Any help is appreciated...
thanks, Dan
 
C

Chip Pearson

Dan,

You can call the CoCreateGuid API function to create a GUID. For
example,

Declare Function CoCreateGuid Lib "ole32" (ByRef GUID As Byte) As
Long

Sub AAA()
Dim ID(0 To 15) As Byte
Dim N As Long
Dim GUID As String
Dim Res As Long
Res = CoCreateGuid(ID(0))
For N = 0 To 15
GUID = GUID & IIf(ID(N) < 16, "0", "") & Hex$(ID(N))
Next N
Debug.Print GUID
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
Top