Show the reader all the components and their interactions
When using a customXML in your Word document this can greatly simplify coding your Word userform. The image below is an overview of the situation I'll document in this tutorial.
The idea is that the customXML stores three types of information:
- data entered by the users
- data to populate controls in both the userform and the content controls
- configuration etc
Goal of the solution is that users can enter information in two ways:
- by opening the userform and entering information there
- by typing information direct in the content controls in the Word document
The macros in the Word document will have two main tasks:
- synchronise information between the userform and the customXML (Userform)
- configure the content controls based on the data in customXML (general macros)
Word will take care of displaying the information (stored in the customXML) in the content controls. Content controls that are linked to the same customXML elements will be synchronised by Word. This means that if information is changed in that customXML element through one content control, all the others will be automatically changed after user exits the content control.
The macros in the Word add-in enable you to add a customXML to your Word document structure. Please have a look at the results of the related tutorial "Smart Data Entry" on how to create these macros.
Now you have an overview of all the components and their interactions. The template contains a userform for user interactions. The userform will retrieve and store its information mainly from/in the customXML. In the body text the Content Controls will take care of displaying this information. The customXML can also be used to populate content controls in the text and the userform.