View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joe joe is offline
external usenet poster
 
Posts: 62
Default How retrieve GUID and Document Properties

Thank you

----- Bob Phillips wrote: ----

Joe

Here is some code to generate a GUI

Private Type GUI
Data1 As Lon
Data2 As Intege
Data3 As Intege
Data4(7) As Byt
End Typ

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

Public Function getGUID(Optional delimited As Boolean = False) As Strin
Dim udtGUID As GUI

If (CoCreateGuid(udtGUID) = 0) The

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 I

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

End Functio

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


Here's a function to get the Doc prop
'----------------------------------------------------------------
Public Function DocumentProperty(Property As String
'----------------------------------------------------------------
Dim oProperty As DocumentPropert
Dim CustomProperty As Boolea
On Error GoTo dp_error
CustomProperty = Tru
For Each oProperty In ActiveWorkbook.BuiltinDocumentPropertie
If LCase(oProperty.Name) = LCase(Property) The
CustomProperty = Fals
End I
Nex
If CustomProperty The
DocumentProperty = ActiveWorkbook.CustomDocumentProperties(Property
Els
DocumentProperty
ActiveWorkbook.BuiltinDocumentProperties(Property
End I
Exit Functio
dp_error
DocumentProperty = CVErr(xlErrValue
End Functio

Use like = documentproperty("Last Save Time"

--

HT

Bob Phillip
... looking out across Poole Harbour to the Purbeck
(remove nothere from the email address if mailing direct

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

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