There are many cases where we need to get the document property without the file being opened in VBA.
This can be achieved by using the objects available in DSOFile.dll. This file can be downloaded from http://support.microsoft.com/kb/224351
Once this downloaded and installed. You need to add a reference to DSO Ole Document's property library (refer image below)
Function GetPropFromDSO(ByVal sFile As String, ByVal sCP As String) As String
Dim oFil As DSOFile.OleDocumentProperties
Dim oCP As DSOFile.CustomProperties
On Error GoTo Err_Tp
Set oFil = New OleDocumentProperties
oFil.Open sFile, True
Set oCP = oFil.CustomProperties
GetRevFromDSO = oCP(sCP)
.Value
oFil.Close
Err_Tp:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Function
The function gets the Filename and the Property to be extracted and returns the property value.
Here are some important custom properties
How to know if a Excel Workbook has Macro without opening it

No comments:
Post a Comment