Resting Anchor

The Anchorage

Personal website of Gregory K. Maxey, Commander USN (Retired)

Enhanced Document Properties AddIn
(A Microsoft Word Help & Tip page by Gregory K. Maxey)

DISCLAIMER/TERMS OF USE

The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.

Click to acces PayPal Verification Service Click to acces PayPal Verification Service

However, the work is mine. If you use it for commercial purposes or benefit from my efforts through income earned or time saved then a donation, however small, will help to ensure the continued availability of this resource.

If you would like to donate, please use the appropriate donate button to access PayPal. Thank you!


The purpose of this Microsoft Word Tips & Microsoft Word Help page is to publish and describe my Enhanced Document Properties global template AddIn for Word.


Note: The template AddIn is a Word Macro-Enabled Template (.dotm) file. If you are not able to use macros in your environment then this solution is not valid for you.

Background\Discussion

Version History

Basics

 Skip to the AddIn Description if you are not interested in the background discussion on document properties.

 Document properties have been a part of Microsoft Word since at least Word 97.  Before Word 2007, there were two types of document properties.  Built-in (a fixed set of properties defined by Microsoft) and Custom (a variable set of properties defined by a document user).

With a basic VBA procedure, you can create a list of both built-in and custom document properties and their values.

VBA Script:
Option Explicit

Sub ListDocProperties()
'A basic Word macro coded by Greg Maxey
Dim oBIProp As DocumentProperty, oCustProp As DocumentProperty
  For Each oBIProp In ActiveDocument.BuiltInDocumentProperties
    On Error GoTo Err_BIProp
    Debug.Print oBIProp.Name & " - " & oBIProp.Value
RE:
  Next oBIProp
  For Each oCustProp In ActiveDocument.CustomDocumentProperties
    Debug.Print oCustProp.Name & " - " & oCustProp.Value
  Next oCustProp
lbl_Exit:
  Exit Sub
Err_BIProp:
  Debug.Print oBIProp.Name
  Resume RE:
End Sub

NOTE - The Enhanced Document Property AddIn and the remainder of this discussion focuses on Built-In document properties and enhancements only. While custom document properties may still have a place in older documents, their function can be performed by other means as the AddIn and discussion will hopefully illustrate.

The following is a lists the built-in document properties and their values found in a new blank document created using Word 2019 with my Normal template.

Site Note IconNotes:
1. This list is little changed since Word 2003.
2. The properties defined in red above are not addressed by the AddIn. They are either not able to be represented in the document with a DocProperty field, unrelated to Word, or pointless (e.g., Application name).

Several built-in document properties can be viewed (and in some cases set) using the File menu Info pane (basic properties/show all properties) view:

EDP_001

Other the built-in document properties can be viewed (and in some cases set) using the File menu Info pane (Advanced properties) view.  In the following illustrations, I have used a more fully developed file:

EDP_002

Site Note IconNotes:
1. Like in the basic properties view, some of the property labels do not match the property name.
2. The General tab lists primarily Windows file properties.  

EDP_003 EDP_004

The Magic Document Properties

Prior to Word 2007 (without using VBA procedures), a built-in document property value could only be displayed as document content using a DocProperty field.  DocProperty fields can be defined manually using the keyboard or inserted and defined using the command bar File>Insert>Field user interface control.

With the release of Word 2007 and the new Ribbon user interface, a method for inserting a list of fifteen seemingly "magic" document properties as document content was introduced:

EDP_005

When a document property is inserted using this method, a DocProperty field is no longer used. Instead the document property is displayed in the document as a plain text content control content.

EHD_006

It didn't take savvy Word user long to realize that there was something really unique about these "so called" document property content controls.

We also see six "new" document properties listed in the Ribbon Document Property menu (Abstract, Publish Date, Company Address, Company E-mail, Company Fax and Company Phone).

 But, hang on!  These six are not in the list generated by the macro shown above.  With some investigation we can see that these six, while unique in their own way, don't behave like the other nine in the list or other document properties in general.

EDP_007
Here we have the Manager document property as a content control followed by a DocPropery Manager field
and the Company Phone document property as a content control followed by a DocPropert CompanyPhone field

EDP_008
Notice that the DocProperty CompanyPhone field does not resolve
 to and display the defined company phone number.

In fact these six "odd ball" document properties are not really document properties at all (or not in the sense of the two types "built-in" or "custom" discussed earlier). They are Microsoft's "pseudo" document properties and the AddIn is going to take Microsoft's approach a bit further.

Site Note IconNote:  The other nine in the Ribbon Document Property menu are associated with a real built-in document property.

The uniqueness and magic behind the fifteen "document properties" listed on the Ribbon menu is that all fifteen are linked to one of three built-in document CustomXMLParts.

Site Note IconNote:  The three built-in document CustomXMLParts cannot be deleted from a document and their XML structure cannot be modified. 

The following illustrates the structure of the three CustomXMLParts and indicates the documents property associated with each XML node:

EDP_009

EDP_010

EDP_011

Since the document property content controls created and displayed in the document using the Ribbon Document Property menu is linked to (or mapped to) the content of its associated CustomXMLNode, when you copy that control to other locations in the document that copy is also linked.  A change to any content control linked to a node, changes that node value and that change is carried over to all other content controls linked to the same node.  That is the "magic" behind these fifteen document properties.

Here is a break down of the behind the scene attributes of the fifteen "magic" document properties:

Limits and Leverage

Unfortunately due to the XML Schema attached to the three built-in CustomXMLParts, the document properties listed on the Ribbon Document Property can only be modified using SharePoint or via advanced XML and XML Schema processes.  E.g., the menu listing "Author" is tied to the built-in document property "Author" that is linked to the XML Node "creator" and menu action inserts a content control is titled "Author."  You can't change it to say "Composer" or add your own customized entries to the list.

Site Note Icon Notes:
  1. SharePoint users can develop a Word document library that results in additional SharePoint defined document properties on the Word built-in Ribbon Document Property menu.  SharePoint is beyond the scope of this discussion.
  2.  These advanced process may be the subject of a future tips page.

Many creative document or template designers have "fudged" and leveraged one or more of these fifteen document properties for other purposes.  For example, a template designer may be creating a template associated with a estate plan or will and wish the have linked content associated with client information (Client name, Client Address, Client Phone ... age, DOB, martial status, number of children, etc.).

This is a simple matter of inserting one of the properties in the document and using Developer>Controls>Properties dialog to change the title of the content control in the document: 

EDP_012

The following illustrates what happens behind the scenes:

EDP_013

Site Note IconNote:  Click on Content Control Tools for more information on and to download and use my Content Control Tool AddIn. 

This solution is satisfactory in some cases but falls short when the template designer needs more than just a few distinct linked content controls.

More complete and customized solutions are certainly available.  Microsoft Word 2013 and later include a XML Mapping Pane where advanced (or at least knowledgeable) users can easily employ and load any number of CustomXMLParts to use for additional mapping.  This AddIn attempts to provide one such highly customized solution.  You be the judge.    

Enhanced Document Properties AddIn

The Enhanced Document Properties AddIn is intended to be placed in the Word Startup folder to load when Word is launched.  The AddIn emulates the built-in Ribbon Insert>Text>QuickParts menu and provides the following document enhancements:

The dynamic Enhanced Document Property menu provides listings for: 

Site Note IconNote: The Ribbon alteration discussed above is also replicated on the Header Footer Tools>Design>Text context tab. 

When placed in the Word Startup folder, or loaded manually, on first use the AddIn displays the user disclaimer.

EHD_014

After accepting the disclaimer and select Insert>Text>QuickParts, the following modified user interface is displayed:

EDP_015

After the accepting the disclaimer, the modified user interface is presented:

  1. The replicated built-in AutoText preview gallery
  2. The replicated built-in PropertyInsert gallery
  3. A new dynamic Enhanced Document Property menu
  4. The replicated built-in FieldInsert button
  5. The replicated built-in BuildingBlock Gallery control
  6. A repurposed Save selection to AutoText button
  7. A new button that links users to this tips page
  8. A new button (the most important button on the interface) that links users to my PayPal Donate link.
  9. A listing of the AddIn default "pseudo" document properties.
  10. A new menu. This menu list most other built-in document properties.
  11. A new button to load a user-defined XML file as a CustomXMPart.   

When the "Other Document Properties" menu is selected the following user interface is presented:

EPD_016

These menu listings are linked to a one of two document CustomXMLPart automatically imported into the active document. A partial listing of the associated CustomXMLNodes for each part is illustrated below:

EDP_017A

EDP_017

Site Note IconNotes:
    1. While the content/structure of the EDP_OtherDocProps CustomXMLPart is not restricted by a custom schema, the content\structure should not be altered.  Any alterations made by the user could and will likely adversely effect AddIn performance.

     2. The content controls displayed in the document for the properties displayed in the EDP_OtherDocProps CustomXMLPart  a DocProperty field. Must of these properties are calculated by Word. Users should not attempt to update or set a property by altering the content control content.  For properties that must be set, use the File>Info basic or advanced properties pane.   

User-defined "Pseudo" Document Properties

Similar to the six unique "Magic Document Properties" discussed above, the AddIn default "pseudo" (and subsequent user-defined) document properties defined in EnhancedDocProps CustomXMLPart are not really document properties at all but simply content linked (or mapped) to a CustomXMLNode.  The difference is the user-defined "pseudo" document properties are linked to a CustomXMLNode (CustomXMLPart) defined by the user.

The following is the XML text of the AddIn default "pseudo" document properties.

EDP_018
  1. The Namespace MUST be as shown: http://TheAnchorage/EDP_UserDefined_PsuedoProperties
  2. Simple Element nodes (no attributes) will produced "pseudo" document properties wrapped in plain text content controls.
  3. Element nodes with "type" attribute node will produce ""pseudo" document properties wrapped the type content control indicated i.e., DDL-DropdownList, CBox-ComboBox, RT-RichText, DATE-Date, PIC-Picture and CHK-Checkbox).
  4. Element nodes with a "type" DDL or CBOX attribute node and a defined LE attribute node will produce as "pseudo" document property of type indicated with list entries as defined by the LE attribute delimited using the pipe "|" characters.

The file containing your user-defined XML must be a .txt or .xml format file. You load your custom file using the Load User-Defined XML as CustomXMPPart button described above. This launches a file picker dialog which you use to navigate to and select your .txt or .xlm file:


EDP_020

1. Navigate to the folder containing the file 2. Select the file 3. Click "OK"

If the selected .txt/.xml file meets the criteria specified above and meets XML structure requirements, the XML file will load and create a new document CustomXMLPart and update the Enhanced Document Property dynamic menu.

I have created a user-define (me) sample file which when loaded, replaces the default list with my defined list:

EDP_021

The associated document CustomXMLPart is illustrated below:

EDP_022

Site Note IconNote: The content/structure of this CustomXMLPart is not restricted by a custom schema. While modification could be made using my Content Control Tools AddIn, if changes are required I recommend changing and reloading the underlying XML file. 

Button commands on the AddIn template QAT can be used to both reload\load revised user-defined "pseudo" document property XML file or reload the AddIn Other Properties CustomXMLPart:

EDP_023

Conclusion

 You can download the AddIn template file and supporting files here: Enhanced Document Properties AddIn. The download is in .zip format and includes the following files.

EDP_024

Site Note Icon For more on template add-ins and how to load them, see: Organizing Your Macros/Template Add-ins at: Installing Macros

Site Note iconNote: This tips page, illustrations and examples were developed using Word 2019. The AddIn should be compatible with all previous Ribbon versions of Word for PC.

That's it! I hope you have found this tips page useful and informative.

Share

PAYMENTS/DONATIONS

Click to acces PayPal Verification Service Click to acces PayPal Verification Service

Do you want to make a payment for consulting work or donate to help support this site?

PayPal is a safe, easy way to pay online.

Use the appropriate currency "Donate" button to make a payment or donation.


Search my site or the web using Google Search Engine

Google Search Logo