Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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



  #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




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
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 09:29 PM.

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"