How to use fields to create a conditional header or footer in a Word document

In the event you run right into a conditional header or footer request which you could’t deal with, check out Phrase fields. They are not magic, however it sort of feels like magic once they do what you need.


Illustration: Lisa Hornung, Getty Pictures/iStockPhoto

If somebody requested you so as to add a conditional header or footer to a doc in Microsoft Phrase, would you panic? Some customers may as a result of the interface affords no such choice. You should use the Totally different Odd & Even Pages choice, however that is not the identical factor. 

A conditional header or footer will show, or not, relying on whether or not an expression returns TRUE or FALSE. On this article, I am going to present you 3 ways to make use of fields to generate a conditional header or footer, though the examples will all be within the footer. 

SEE: 83 Excel ideas each consumer ought to grasp (TechRepublic)

I am utilizing Microsoft 365 on a Home windows 10 64-bit system, however you need to use earlier variations. Phrase fields have been round for a very long time. This text assumes you’ve gotten primary Phrase expertise, however even a newbie ought to be capable of comply with the directions to success. You may obtain the demonstration .docx and .doc recordsdata, however I encourage you to apply coming into the fields your self. Phrase On-line does not show headers and footers; nor are you able to manipulate them. Nevertheless, they’re nonetheless there, and they’re going to print.

What’s a discipline in Phrase?

In the event you’re aware of Phrase fields, you are a step forward. If not, they are not tough to make use of, however the course of may really feel a bit odd at first. Fields are little applications that full a selected process, just like a macro, however you need not write any code. All the pieces the sphere must do its job is already there, aside from the knowledge you provide. 

You employ fields nearly each time you utilize Phrase, however you simply do not realize it. As an example, if you use the interface to show a web page quantity within the header or footer, you are utilizing a discipline! If you would like to see that at work, open a brand new doc and enter a web page quantity within the header. Then, choose the web page quantity and press Alt + F9. Phrase converts the web page quantity to its underlying { PAGE } discipline. On this mode, you possibly can modify the sphere. Press Alt + F9, which acts as a toggle, once more to see the web page quantity. 

The expression to show on final web page of the Phrase doc

It is common to show a special header or footer on the primary or final web page of a doc. You should use the built-in Totally different First Web page choice to show a special header on the primary web page. There isn’t any such choice for the final web page; figuring out the final web page requires a easy discipline expression within the type

{ IF {PAGE} = { NUMPAGES }, “true textual content” “false textual content”}

It is easy to decipher: If the present web page quantity, { PAGE } equals the whole variety of pages, { NUMPAGES } print “true textual content”. If the 2 web page numbers do not match, the expression prints “false textual content”.

Let’s take a look at a fast instance utilizing a three-page doc:

  1. Open the header or footer by double-clicking within the prime or backside margin.
  2. Phrase will place the cursor on the left margin, which is okay.
  3. On this subsequent half, we’ll be coming into the fields manually, which I believe is the best strategy to enter nested fields. To insert a clean discipline, press Ctrl + F9 and sort IF. (Case does not actually matter.) 
  4. Whereas nonetheless contained in the If discipline, press Ctrl + F9 a second time to enter a clean discipline and enter PAGE.
  5. Transfer the cursor to the fitting of the closing } character within the { PAGE } discipline and enter =.
  6. Press Ctrl + F9 a 3rd time and enter NUMPAGES.
  7. Transfer the cursor to the fitting of the closing } character within the NUMPAGES discipline and enter “Final web page” “Not the final web page”.

Determine A reveals the nested fields. Don’t enter the {} characters from the keypad; it will not work. You need to enter the clean fields utilizing Ctrl + F9 and enter the content material inside these brackets. Now, choose your complete nested discipline expression and press Alt + F9 to guage the outcomes (Determine A). As you possibly can see, the final web page is the present web page. 

Determine A


  Use a nested discipline expression to create a conditional header or footer.

I’ve proven you just one strategy to enter fields, however there are different strategies. Earlier than we proceed, I wish to share one other strategy to enter nested fields that you simply may discover simpler. You may kind the sphere identify, akin to IF or NAME, choose that identify and press Ctrl + F9. Doing so will convert IF or NAME to a discipline and insert the brackets.  

This easy expression works high-quality till you’ve gotten unnumbered pages in your doc. As an example, the doc might need a desk of contents or a title web page that you don’t need within the web page rely. When this occurs, you should discover a strategy to accommodate these pages. 

SEE: Home windows 10: Lists of vocal instructions for speech recognition and dictation (free PDF) (TechRepublic)

In the event you’re excluding solely the primary web page, use the Totally different First Web page choice. Doing so will inhibit a web page quantity, and Phrase will not embrace that web page within the closing web page rely. Excluding different pages may require a bit break or an expression that evaluates these pages. The next expression excludes a two-page part firstly of the doc that is not included within the whole web page rely:

{ IF {PAGE} = { NUMPAGES – 2 } , “Final web page” “Not the final web page”}

The expression is sort of the identical as the primary, however the -2 element subtracts 2, the whole variety of pages you wish to exclude from the web page rely. 

If you would like the expression to return nothing, use the empty string character, “”. For instance, the next nested discipline expression will return a string on the final web page and return nothing on all different pages:

{ IF {PAGE} = { NUMPAGES } , “” “Not the final web page” }

Now let us take a look at a situation that appears a bit extra complicated.

Easy methods to specify web page numbers in a footer in Phrase

What occurs when you’ve gotten a footer that you simply wish to print solely on particular pages? You employ the identical fields to specific the particular web page numbers and use the suitable true and false textual content. Let’s suppose that you simply wish to print a web page quantity solely on pages 5 and 6?

The issue solely appears extra complicated, however in fact, it is easier. As an alternative of a nested expression, use two expressions:

{ If {Web page } = “5” “Web page 5” “” }

{ If {Web page } = “6” “Web page 6” “” }

Determine B reveals the web page quantity on web page 6.

Determine B


  Use two expressions to fulfill the pages 5 and 6 situation.

Each situations are easy to fulfill utilizing two totally different expressions as an alternative of a nested expression. Now, let us take a look at one thing you may suppose not possible utilizing fields.

Easy methods to show a picture in a header or footer in Phrase

If requested in case you can show a conditional picture within the header or footer, you may reply, “No.” That is not appropriate. You deal with a picture the identical as some other textual content or worth. First, you should insert the picture file into the doc and put it aside as AutoText. Then, you insert the AutoText into the footer or header. 

First, let’s add TechRepublic’s brand to the doc as an AutoText factor:  

  1. Insert the image into the physique of the doc (not a header or footer) as you’d some other picture file. 
  2. Choose the picture and click on the Discover Fast Elements dropdown. 
  3. Select Save Choice to Fast Elements Gallery.
  4. Within the ensuing dialog, give the picture a reputation, akin to TRLogo (see Determine C). 
  5. Click on OK. 

Determine C


  Title the picture one thing significant so it is simple to recall.

Now that you’ve got the picture as an AutoText merchandise within the doc, you possibly can insert it into the header as follows: 

  1. Place the cursor within the header or footer the place you need it to look. 
  2. Utilizing Determine D as a information, enter the { IF } discipline as much as the primary ” character. 
  3. Click on the Insert tab. 
  4. From the Discover Fast Elements dropdown (Textual content group), select AutoText. 
  5. Choose the picture (Determine E) and click on OK. 

Determine F reveals the brand within the footer, conditionally; it seems solely on the final web page due to the conditional discipline expression proven in Determine D.

Determine D


  Enter the sphere expression as much as the brand picture. 

Determine E


  Choose TRLogo, the picture AutoText you beforehand added. 

Determine F


Fields are so versatile which you could even show a picture conditionally.

This introduction to displaying conditional content material, together with photographs, in a doc’s header or footer is just the start. You should use the next comparability operators: =, <>, <=, and >=. You’ve got discovered tips on how to nest fields, which is extraordinarily helpful. Nevertheless, even when you may use a nested expression, you do not all the time must, as proven within the second instance. Keep in mind to all the time use F9 to insert and modify fields. 

Keep tuned

I discussed earlier that there are extra methods to enter fields than the one I labored you thru within the first instance. A future article will embrace the entire methods to enter Phrase fields. 

Additionally see

Recent Articles


Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox