Possible to generate a GUID in Excel?

  • Thread starter Thread starter Dan
  • Start date Start date
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
 
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
 
Thank you!!!! I had looked around a bit for a way to do this in Access, and nobody mentioned this technique. You have solved my problem very nicely. It was so great to find this, that I created a login so that I could get in here and thank you.
 
Back
Top