Training: advanced usage of the MS Word {if} field code

Created on 2010-10-12 by Sona Gabrielyan

Switzernet

 

 

 

Introduction. 1

Training session. 1

Validation. 4

Références. 5

 

 

Requirements

 

Before you start, please make sure you followed for following training sessions:

- Introduction to MS Word field codes

- {If} field code introduction

- MS Word {if} field code. Nested statements

- MS Word Styles

 

Introduction

 

During this exercise we will look into an example of advanced usage of nested {if} field codes in MS Word document.

 

Training session

 

In order to indicate the place in the document where we define parameters using field codes, we surround them by square brackets (“[ ]”).

 

Figure 1 shows the definitions of parameters which we will use during this training session.

 

Figure 1. Definitions of parameters

 

Ones defined, parameters can be included in any text throughout the same document, making it “dynamic”. If we change the values of parameters defined in the beginning of the document, ones updated, all the texts containing parameters will show the new values.

 

We update a field code by select->right click->Update field or by printing of any single page of the document.

 

Remember, that the curly brackets of field codes must be called using CTRL+F9 and not by just writing {} using the keyboard.

 

Figure 2 shows how to insert a parameter (field code) in a text and how to show its value (the result of the field code).

Figure 2. Display of values of parameters (results of field codes)

 

Using the {if} statements, we form the “composed definitions” (see Figure 3). To have a better understanding of nested {if} statements, we use the color and formatting conventions described in the following document: format_conventions

 

Figure 3. Composed definitions

 

In composed definitions, we check the values using {if} field code and fill the text parameter accordingly. As we can see in Figure 3, same formulas for setting text and short variables are repeated three times. Before each repetition of mentioned formulas, we change the set of parameters pay, long, days and low.

 

First, parameters pay, long, days and low are set to pay1, long1, days1, and low1. Then the value of the text is generated and saved in text1. Then pay, long, days and low are set to pay2, long2, days2, and low2. Then same condition check is done, text is generated and saved this time in text2. Then this action is repeated for the set pay3, long3, days3, and low3.

 

While generating the final textall, we check if text1, text2 and text3 are empty and compose the value accordingly. See the value of textall and shortall parameter in Figure 4

 

Figure 4. Value of “textall” and “shortall” parameters

 

Using the parameters defined via field codes, we can compose a “dynamic” text of announcement. The version with detailed description is presented in Figure 5 and Figure 6.

 

Figure 5. Text of an announcement containing parameters (field codes)

 

Figure 6. Text of an announcement with results of field codes (pink)

 

A version with short description of announcement is presented in Figure 7 and Figure 8.

Figure 7. A version of announcement with short description of the offer showing usage of field codes

 

Figure 8. The results of field codes used in short version of announcement (pink)

 

 

Validation

 

You must generate your own text for announcement (e.g. announce for a scientific conference, announce for a language training sessions, etc). You must have three ranges of parameters in your announcement (e.g. “from” - “to” dates and “from” - “to” rates).

 

Additionally, create three other parameters: fname, lname, training_date. The value of fname is your first name, lname is your last name, and training_date is the current date. At the end of the text of announcement, add the following sentence “Created by xxx yyy, on zzz”. Where xxx is the value of the fname, yyy the value of the lname and zzz is the value of the training_date.

 

Make printscreens corresponding to Figure 1, Figure 3, Figure 5, Figure 6, Figure 7 and Figure 8.

Make a prinscreen of your “Styles and Formatting” pane.

Open a new doc file and copy all mentioned printscreens into that new doc file. The doc file with prinscreens must be uploaded on the training session web site, according to the guidelines.

 

 

References

 

MS Word Field Reference: http://office.microsoft.com/en-us/word-help/CH006104723.aspx?CTT=97

{if} field code reference: http://office.microsoft.com/en-us/word-help/field-codes-if-field-HP005186163.aspx

Format (\*) field switch: http://office.microsoft.com/en-us/word-help/format-field-switch-HP005186222.aspx

Introduction to MS Word field codes: http://switzernet.com/3/support/100914-word-form-fields-introduction/

{If} field code introduction: http://switzernet.com/3/support/101001-word-if-field-introduction/

MS Word Styles: http://switzernet.com/2/support/091026-training-MS-Word-style/

Training sessions: http://www.unappel.ch/2/support/100722-training-employees/i/

 

 

*   *   *