Using VBA, how can I get access to the Document Properties of a Word file without opening the document?

Article contributed by Jonathan West

Microsoft makes an ActiveX DLL available called dsofile.dll, which allows you to read & write the document properties of an Office file without opening the file in a document editing window. To obtain it, go to Q224351

Note:  Microsoft has updated DSOFile.dll to version 2, compatible with .NET.  The template referenced in this article has been updated to use the later version of DOSFile.dll.

The download includes the DLL itself, plus the source code for a small VB5/VB6 project that demonstrates its use. While the VB code can't be used unmodified in VBA, looking at it should give you a pretty good idea of how to use the DLL.

In addition, you can download a template called ListProps.dot (Lene Fredborg: link to file removed 3-Feb-2017) that will use dsofile to list all the Office documents in a folder, including whichever of the built-in document properties you want to have.

To run it, proceed as follows.

  1. Download and register dsofile.dll using regsvr32.
  2. Copy the ListProps template into your Word startup folder.
  3. Start Word. A new entry will appear in the Tools menu.
  4. Select the entry. In the dialog that appears, select the properties you want to include in your list, select the folder you want to have listed, and select the template you want to use as the document type for the list.

ListProps then uses dsofile to open each file in turn, get the properties, and puts the list into a table. Works with available properties of Word, Excel & PowerPoint files.