#1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 26
Default Create A GUID

I wish to create a GUID in a cell. I could put it on a macro button on the
toolbar. Does Excel have anything built in to do this, or do I need VBA
code. I would appreciate a sample.

Derek


  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,452
Default Create A GUID

Private Declare Function CoCreateGuid Lib "ole32" (Id As Any) As Long

Function CreateGUID() As String

Dim btID(0 To 15) As Byte
Dim i As Long

If CoCreateGuid(btID(0)) = 0 Then
For i = 0 To 15
CreateGUID = CreateGUID + IIf(btID(i) < 16, "0", "") + Hex$(btID(i))
Next i
CreateGUID = Left$(CreateGUID, 8) & "-" & _
Mid$(CreateGUID, 9, 4) & "-" & _
Mid$(CreateGUID, 13, 4) & "-" & _
Mid$(CreateGUID, 17, 4) & "-" & _
Right$(CreateGUID, 12)
Else
MsgBox "Error while creating GUID!"
End If

End Function


Sub test()

Cells(1) = CreateGUID()

End Sub



RBS



"Derek Hart" wrote in message
...
I wish to create a GUID in a cell. I could put it on a macro button on the
toolbar. Does Excel have anything built in to do this, or do I need VBA
code. I would appreciate a sample.

Derek


  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 284
Default Create A GUID

Here is an option.

________________________

Sub GenerateGUID()
Dim strGUID As String
Set TypeLib = CreateObject("Scriptlet.TypeLib")
strGUID = Left(TypeLib.GUID, 38)
Cells(1, 1).Value = strGUID
Set TypeLib = Nothing
End Sub

_________________________

Steve Yandl



"Derek Hart" wrote in message
...
I wish to create a GUID in a cell. I could put it on a macro button on the
toolbar. Does Excel have anything built in to do this, or do I need VBA
code. I would appreciate a sample.

Derek



  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 45
Default RB, Can I ask A ? About Lib OLE32

I see helpful geniuses often refer to windows libs in the forums, where do I
find documentation on these libs, like how did you know ole32 had the guid
feature? Thx

"RB Smissaert" wrote:

Private Declare Function CoCreateGuid Lib "ole32" (Id As Any) As Long

Function CreateGUID() As String

Dim btID(0 To 15) As Byte
Dim i As Long

If CoCreateGuid(btID(0)) = 0 Then
For i = 0 To 15
CreateGUID = CreateGUID + IIf(btID(i) < 16, "0", "") + Hex$(btID(i))
Next i
CreateGUID = Left$(CreateGUID, 8) & "-" & _
Mid$(CreateGUID, 9, 4) & "-" & _
Mid$(CreateGUID, 13, 4) & "-" & _
Mid$(CreateGUID, 17, 4) & "-" & _
Right$(CreateGUID, 12)
Else
MsgBox "Error while creating GUID!"
End If

End Function


Sub test()

Cells(1) = CreateGUID()

End Sub



RBS



"Derek Hart" wrote in message
...
I wish to create a GUID in a cell. I could put it on a macro button on the
toolbar. Does Excel have anything built in to do this, or do I need VBA
code. I would appreciate a sample.

Derek



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create adress list so can mail merge and create labels? adecocq Excel Discussion (Misc queries) 2 October 25th 06 12:32 AM
how to create a combo box in excel - how to create the drop down . @evy Excel Discussion (Misc queries) 2 August 18th 06 12:17 PM
How to create a form to insert a hyerlink.VBA code to create a for karthi Excel Discussion (Misc queries) 0 July 5th 06 11:26 AM
Create dictionary of terms, create first time user site Solitaire Jane Austin New Users to Excel 1 January 19th 06 09:47 PM
need to create a formula to create a timesheet but haven't a clue AHurd Excel Discussion (Misc queries) 7 August 22nd 05 12:04 PM


All times are GMT +1. The time now is 03:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"