ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Possible to generate a GUID in Excel? (https://www.excelbanter.com/excel-programming/286872-possible-generate-guid-excel.html)

Dan[_29_]

Possible to generate a GUID in Excel?
 
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



Chip Pearson

Possible to generate a GUID in Excel?
 
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


"Dan" wrote in message
...
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[_29_]

Possible to generate a GUID in Excel?
 
ahhh, yes, I should have known that! Thanks!
dan

"Chip Pearson" wrote in message
...
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


"Dan" wrote in message
...
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








All times are GMT +1. The time now is 12:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com