LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How retrieve GUID and Document Properties

Joe,

Here is some code to generate a GUID

Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type

Private Declare Function CoCreateGuid Lib "OLE32.DLL" (pGuid As GUID) As
Long

Public Function getGUID(Optional delimited As Boolean = False) As String
Dim udtGUID As GUID

If (CoCreateGuid(udtGUID) = 0) Then

getGUID = _
String(8 - Len(Hex$(udtGUID.Data1)), "0") & Hex$(udtGUID.Data1) & _
String(4 - Len(Hex$(udtGUID.Data2)), "0") & Hex$(udtGUID.Data2) & _
String(4 - Len(Hex$(udtGUID.Data3)), "0") & Hex$(udtGUID.Data3) & _
evalChar(udtGUID.Data4(0)) & Hex$(udtGUID.Data4(0)) & _
evalChar(udtGUID.Data4(1)) & Hex$(udtGUID.Data4(1)) & _
evalChar(udtGUID.Data4(2)) & Hex$(udtGUID.Data4(2)) & _
evalChar(udtGUID.Data4(3)) & Hex$(udtGUID.Data4(3)) & _
evalChar(udtGUID.Data4(4)) & Hex$(udtGUID.Data4(4)) & _
evalChar(udtGUID.Data4(5)) & Hex$(udtGUID.Data4(5)) & _
evalChar(udtGUID.Data4(6)) & Hex$(udtGUID.Data4(6)) & _
evalChar(udtGUID.Data4(7)) & Hex$(udtGUID.Data4(7))
End If

If delimited Then
getGUID = Left(getGUID, 8) & "-" & _
Mid(getGUID, 9, 4) & "-" & _
Mid(getGUID, 13, 4) & "-" & _
Right(getGUID, Len(getGUID) - 17)
End If

End Function

Private Function evalChar(char)
evalChar = IIf(char < &H10, "0", "")
End Function


Here's a function to get the Doc props
'-----------------------------------------------------------------
Public Function DocumentProperty(Property As String)
'-----------------------------------------------------------------
Dim oProperty As DocumentProperty
Dim CustomProperty As Boolean
On Error GoTo dp_error:
CustomProperty = True
For Each oProperty In ActiveWorkbook.BuiltinDocumentProperties
If LCase(oProperty.Name) = LCase(Property) Then
CustomProperty = False
End If
Next
If CustomProperty Then
DocumentProperty = ActiveWorkbook.CustomDocumentProperties(Property)
Else
DocumentProperty =
ActiveWorkbook.BuiltinDocumentProperties(Property)
End If
Exit Function
dp_error:
DocumentProperty = CVErr(xlErrValue)
End Function

Use like = documentproperty("Last Save Time")

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Joe" wrote in message
...
I'm using XL 2002 and would like to retrieve a GUID from the system. Does

anyone know an API call that I can use? I would also like to access the
document properties. Does anyone know the VBA required to do so.

Thanks,

Joe



 
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
Document Properties Bauhinia Excel Discussion (Misc queries) 1 October 23rd 07 12:33 PM
How do I unlock document properties? MarvaT Excel Discussion (Misc queries) 1 August 10th 06 05:17 PM
Properties of a document, help! Jason Excel Worksheet Functions 2 February 24th 06 10:47 AM
Document Properties Barb R. Excel Worksheet Functions 5 May 23rd 05 04:55 PM
How retrieve GUID and Document Properties pikus Excel Programming 0 May 5th 04 04:13 PM


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

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

About Us

"It's about Microsoft Excel"