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!
The purpose of this Microsoft Word Tips & Microsoft Word Help page is to extend the theme of "ADCAP (Advance Capability) Content Controls" and illustrate methods for creating grouped mutually exclusive content control check boxes (which function as option buttons) and grouped check boxes with a defined selection limit.
Typically check boxes shouldn't be used in an exclusive situation and your document user's are expected to check one check box, no check box or all that apply as illustrated below.
When option buttons are employed, the user is typically expected to choose, and should be restricted to choosing, only one listed item.
Using the content control properties dialog, you can define symbols for the content control check box "checked" and "unchecked" state and make the checkbox resemble option buttons (sometimes called radio buttons):
However, "out of the box" there is nothing in Word that limits the user to one selection:
Using the methods described in this tips page, you can ensure the user selection is processed in real time and create option buttons in your documents so the user is limited to a single selection as following video illustrates.
Method 1 employs an adaptation of my Content Control Custom Events technique, a careful convention for defining the content control "tag" property, and a little VBA wizardry.
VBA code in the custom event procedure ensures that only one option button in a defined group can be in the checked state at any given time.
All of the required VBA code is available in the "ThisDocument" module of the VB Project of the template which you can download using the link at the end of this tips page.
While the code may appear daunting to novices, it is really quite simple and works basically like this:
Note: The optional "Other/Please Specify" shown in the video is a feature of Method 1 and the Add-In only.
Your documents may have one or more mutually exclusive content control option button groups. The key is the careful application of "tags" to your check boxes and the optional user defined text content controls.
The following illustrates a properly tagged check box used as an option button and a properly tagged optional user defined text content control.
Defining and tagging a large number of content controls can be tedious. Accordingly, I've created a full featured Word Template Add-In that facilitates creating ADCAP content control check boxes for you automatically. The add-in is described in more detail later in this tips page.
Method 2 utilities content control mapping and the pseudo "OnChange" property of the built-in Document_ConentControlBeforeStoreUpdate event.
While this method uses the built-in events, it is significantly more complicated and unfortunately, after hours and hours of testing and experimentation, I discovered that the controls and processes will not perform as expected when the user applies editing restrictions to the document.
Note: The basic concept of this method was proposed by former Word MVP and friend Peter Jamieson.
As with Method 1, all of the required VBA code is available in the "ThisDocument" module of the VB Project of the template which you can download using the link at the end of this tips page.
A complete discussion of content control mapping is beyond the scope of this tips page. Stated simply, content control mapping is a process of binding content controls to a XML node. When bound to a node the content control value (or state in the case of checkboxes) is determined by the value of the node.
This method works basically by using the Document_ContentControlBeforeStoreUpdate event to ensure that if any content control check box bound to an attribute child node of an identified parent node is checked, then all other content control check boxes bound to other attribute child nodes of that same parent node are unchecked.
Due to the shortcoming mentioned above, this method is half-baked so to speak, and is only provided for those people who might be interested in the code. It was not developed further as a functional add-in.
After the big disappointment of discovering method 2 described above fails when employed in documents with editing restriction, I had to change course and further develop method 1. The tasks was certainly challenging and frustrating at times, but in the end it was rewarding and I think the effort was worthwhile.
Note: The controls on the UI may be dimmed and unavailable if there is no active document open or if the document is not compatible with Word 2010 or higher. Since content control checkboxes were not available in Word before Word 2010, the Add-In will not support documents created in earlier versions.
I have tried to make this Add-In as user friendly as possible and eliminate any need for users to understand or need to deal with VBA coding. However, each document in which you want to incorporate ADCAP Content Control check boxes, must have specific code in the "ThisDocument" module of document VB project.
The add-in will automatically perform a cursory check for the existence of the correct code when you attempt to create ADCAP Content Control check boxes.
This feature requires access to the document VBA object project module. In order to get access, you must set the option "Trust access to the VBA object module" using File>Options>Trust Center>Trust Center Settings>Macro Settings and then click OK.
To mitigate security risks, after you have created your ADCAP Content Control Check Boxes you should return to the Trust Center and remove access o the VBA project object module.
If the check fails, and the "ThisDocument" module contains no code, the Add-In automatically inserts the required code in the active document "ThisDocument" module.
If the check fails, and the "ThisDocument" module contains code, the Add-In automatically prompts the user to refresh the existing code with the required code.
If you click "Refresh Code," the Add-In looks for specific named procedures in the VB project. If a named procedure is not found, the Add-In automatically adds the required procedure. If the named procedure is found, the Add-In prompts the user to replace the found procedure as illustrated below:
Clicking "Yes" replaces the procedure. Clicking "No" displays the following user notification:
If you click "Cancel" or "No" in the aforementioned dialogs, then I have to assume that you know enough about VBA code to evaluate your existing code and the code required by the Add-In in order to ensure the Add-In features will function as required.
For example, you might have existing code in the built-in Document_ContentControlOnEnter event. If this is the case you will need to incorporate the required elements of the Add-In Document_ContentControlOnEnter event into your existing event.
Notes: If the check procedure is found, the Add-In "does not" validate that all of the code in your "ThisDocument" module is the correct code. See: "Clicking Add or Refresh Code" below.
Using this dialog, you:
1. To create a group of mutually exclusive option buttons, the cursor must be located in an empty paragraph.
2. When a pre-defined symbol pair is selected, the character number and fonts fields display the character numbers and font names of the the selected pairs.
3. Version 1.1 introduces the pre-defined symbol pair lists. This feature was prompted by a suggestion by my long time friend Graham Mayor. In addition to his typical outstanding reviews and comments on my projects, he now seems to enjoy adding a bit of his polish to my projects as much as I enjoy doing the same to his!
Using the Add-In you can create three types of ADCAP Content Control Check Boxes with a variation of one type.
When groups are defined and added to the document, they are added as a continuous text string in the empty paragraph. After adding, you can relocate and add additional test as required.
Note: In version 1.2. not illustrated below, I replaced the spaces separating the option buttons with tabs.
After you have gone to the trouble of adding multiple groups of ADCAP Content Control check boxes to a document or template, I assume that you want them to stay there and not be easily deleted by a careless user.
I have also assumed that you will restrict editing in your template\document. See: Content Control Fill-in Form.
This button sets the content control "Content Control cannot be deleted" property on all ADCAP Content Control check boxes in the document and adds a "wdEditorEveryone" editor to the control range.
This button clears the content control "Content Control cannot be deleted" property, if set, and deletes:
This button removes "ALL" editors for all ADCAP Content Control check boxes in the document.
Clicking this button simply provides a means to "confirm" and manually load or restore the required code to the default values required by the add-in.
Note: This tips page, illustrations and examples were developed using Word 2010. It is wholly functional with Word 2013.
The rest I think is self explanatory, so that's it! I hope you have found this tips page useful and informative. You can download the templates containing both methods, the examples used to create this tips page, and the Add-In here: Templates.
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.