VBA Document Properties


Document Built-in Properties


Document Custom Properties


DSOFile.dll - Accessing Document Properties without opening the files

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.


This includes a template called ListProps.dot 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.
Download and register dsofile.dll using regsvr32.
Copy the ListProps template into your Word startup folder.
Start Word. A new entry will appear in the Tools menu.
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.



How to use a single VBA procedure to read or write both custom and built-in Document Properties

When you work with Document Properties in code, most people end up with two functions or subroutines, one to write built-in Document Properties and one for custom Document Properties; because in each case the object used to refer to the Document Properties is different - you have to use the CustomDocumentProperties and BuiltinDocumentProperties collection as appropriate. But this can be very inconvenient.
Writing Document Properties
However, you can write a procedure which checks whether the property you want to write the value for is custom or built-in, and then uses the appropriate collection. (Note: If you are not familiar with calling subroutines with arguments, see: How to cut out repetition and write much less code, by using subroutines and functions that take arguments).




Reading Document Properties

The same principle can be used when reading Document Properties:


We could call the function like this:



© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext