Personal website of Gregory K. Maxey, Commander USN (Retired)
Do you have ad-blocking software enabled? While I respect your right to do so, your donations and the minimal advertisements on this site help to defray internet and other costs of providing this content. Please consider excluding this website from blocking or turning off the blocker while browsing this site.
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!
This Microsoft Word Tips & Microsoft Word Help page consolidates and expands on methods methods previously published on this website for linking document conditional content to a selection made in a document list control.
Conditional content is variable content determined or defined by a condition. When a document user selects an entry (e.g., person's name) from a document list control, they have created a condition.
As the document designer you may want to link that condition to variable data (e.g., an address and phone number associated with the person selected) as illustrated in the following video.
The video illustrates an advanced method using a content control dropdown list and two plain text content controls "content ranges" to display the conditional content. It works brilliantly for me. If you, as the document designer, have access to Word 2007 or higher it could work for you.
It is completely useless if the document user is limited to Word 2003 (and lower) or not permitted to enable and run macros!
This tips page provides multiple methods for linking conditional content to the following list control types:
All of the methods except one of the formfield methods requires some VBA (macro) to run.
When considering which method is best (if any) to employ in your document design, you should keep the document user and his/her limitations and restrictions in mind.
Each of the methods for the four types of list controls is demonstrated and fully described in a four part series of demonstration documents. You can download the documents here or using the link at the end of this tips page.
Each of the demonstration documents contain a VBA code module and one or more "content ranges."
Note: "Content ranges" refers to the target, or holder, of the conditional content displayed in the document. These include fields, document variables, bookmarks, table cells, formfields, content controls, and ActiveX controls.
The VBA project can be accessed by pressing ALT+F3 to open the Visual Basic Editor (VBE). With the VBE open, press Ctrl+r to display the Project Explorer then look for and expand the project.
In addition to the "ThisDocument" module, each project will contain one or more standard modules and a form module. Dbl-click to expand and view the modules.
Use can set stops in the code by clicking in the gray horizontal bar on the right side of the large code editing pane. When the code is executed, it will run to the stop. You can then step through and observe the code processes using the F8 key.
Fields (e.g., IF and DocVariable) can be created with the user interface (e.g., Insert>QuickParts>Field) or directly using CTRL+F9.
Field code/results can be toggled globally in the document using Ctrl+a (select all) followed by ALT+F9.
Bookmarks are created and viewed with the user interface Insert>Links>Bookmark control.
Formfields and ActiveX controls are created using the Developer>Controls>Legacy Tools gallery.
Formfield properties are defined by dbl-clicking the formfield in unprotected mode.
ActiveX control properties are set using the Developer>Controls>Design Mode and right clicking on the control. Lists are defined using code in the project module.
Content controls are created and properties set using the Developer>Controls group and the group "Properties" control.
Each of the demonstration documents describes methods for employing short static fictional list entries and variable conditional content directly in the control or associated VBA code.
For longer lists, dynamic methods using external data (e.g., Word table, Excel worksheet) are provided. The following illustrates the content of the external Excel file used in the demonstration documents.
Notes: For the dynamic list features to work, you will need to save the companion Excel file "Data Store.xlsx" with demonstration documents in the same folder on a local drive. Attempting to use the dynamic features when the files are store on a cloud drive such as OneDrive results in a run-time error. I'll update this page if I find a solution to the error.
Each of the demonstration documents illustrates a method to link the condition created in a primary list to a dependent secondary list. The following videos illustrates the formfield (legacy) dropdown list method:
Note: Unlike the advance content control method illustrated in the first video, all of the formfield methods and most of the content control methods requires a user initiated exit event before the conditional content is displayed.
The Formfield method demonstration document illustrates the only method to link conditional text that does not require VBA (enabled macros). This method relies on the "Calculate on exit" property of the formfield to update what can easily become a very complex nest of conditional IF fields. The representative field code to display the required address and phone number for a there (3) item list is illustrated below:
VBA code is provided in each of the demonstration documents to populate conditional text in several different content ranges. The Userform demonstration document provides comprehensive methods for populating:
The Content Control demonstration document provides a method for to link and display content other than text (e.g., graphics). This method can be difficult to setup but the result shown in the following video may be worth your effort.
Note: The Content Control demonstration document VBA project contains a special code module "Accessibility" and a procedure that forces that forces the "Developer" tab to display if used with Word 2007. This is required to work around the bug described in my Content Controls tips page.
That's it! I hope you have found this tips page and the companion demonstration documents useful and informative. Download the demonstration document set here: Demonstration Document Kit
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.