PC Review


Reply
Thread Tools Rate Thread

Create A GUID

 
 
Derek Hart
Guest
Posts: n/a
 
      23rd Dec 2007
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 With Quote
 
 
 
 
RB Smissaert
Guest
Posts: n/a
 
      23rd Dec 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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 With Quote
 
Steve Yandl
Guest
Posts: n/a
 
      24th Dec 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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 With Quote
 
headly
Guest
Posts: n/a
 
      24th Dec 2007
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
create a guid Mr. X. Microsoft VB .NET 8 25th Jan 2010 02:13 PM
What is Create GUID Mis Dep. Microsoft VB .NET 6 27th Oct 2004 01:20 PM
Create GUID in C# Jeff Lynch Microsoft Dot NET Framework 2 30th Aug 2004 01:39 AM
Create GUID Grey Microsoft ASP .NET 1 6th May 2004 10:38 AM
New GUID(guidstring) fails to create GUID - Help Please!!! Chris Ericoli Microsoft Dot NET 1 29th Oct 2003 06:04 AM


Features
 

Advertising
 

Newsgroups
 


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