The Anchorage
Personal website of Gregory K. Maxey, Commander USN (Retired)
The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.
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.
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.
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.
Notes:
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:
Other 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:
Notes:
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.
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:
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.
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.
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.
Note: 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.
Note: 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:
Since the document property content controls created and displayed in the document using the Ribbon Document Property menu are 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:
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.
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:
The following illustrates what happens behind the scenes:
Note: 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.
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:
Note: 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.
After accepting the disclaimer and select Insert>Text>QuickParts, the following modified user interface is displayed:
After the accepting the disclaimer, the modified user interface is presented:
When the "Other Document Properties" menu is selected the following user interface is presented:
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:
Notes:
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.
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.
"Foot" Note: Apparently by this point my eyes where
bleeding and I've made several typos in the illustrations. At any point
you see "psuedo" or "difined" in the text or graphics, the correct terms are
"pseudo" and "defined."
The following is the XML text of the AddIn default "pseudo" document properties.
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:
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:
The associated document CustomXMLPart is illustrated below:
Note: 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:
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.
For more on template add-ins and how to load them, see: Organizing Your Macros/Template Add-ins at: Installing Macros
Note: 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.
The information, illustrations and code contained in my "Microsoft Word Tips" are provided free and without risk or obligation.
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!