Sunday, November 06, 2011

How to Extract Properties from Excel/Word without Opening File using VBA

How to get CustomProperties from Excel Workbook/Word Document (VBA) without physically opening the file

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

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)

If Err <> 0 Then
    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

Related Posts Plugin for WordPress, Blogger...

Visual Basic for Applications (VBA) Forum (recent threads)

CodeKeep VBA Feed

Visual Studio Tools for Office Forum (recent threads)

Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.

Office Business Applications (OBA) Team Blog

MSDN Code Gallery Published Resources For Tag VSTO Google Group