Get and Set Microsoft Word Custom Document Properties

Here’s a quick snippet that details how to get and set custom document properties in Microsoft Word documents:


3 thoughts on “Get and Set Microsoft Word Custom Document Properties

  1. I’ve been trying to get this to work on two different Windows 10 computers, one running Office 2013 (msi) and the other running Office 2016 (msi).  I get an error stating “Object reference not set to an instance of an object” on line 10 ($customPropertiesType = $customProperties.GetType()).  

    Interestingly, this problem does not occur on a Windows Server 2012 R2 machine running Office 2013.  I’ve tried similar scripts from the scripting guys and other sites, but this same problem keeps arising.  I don’t know enough about theses objects and methods to understand why this would work in Windows Server 2012R2 but not on Windows 10.  Any ideas?

  2. Hi,

    I solved this by disabling line 10. And replace every “$customPropertiesType” by “[System.__ComObject]”, line 16 and 21.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.