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

3 years ago 276

If you tally into a conditional header oregon footer petition that you can't handle, instrumentality a look astatine Word fields. They're not magic, but it benignant of feels similar magic erstwhile they bash what you want.

word-illustration.jpg

Illustration: Lisa Hornung, Getty Images/iStockPhoto

If idiosyncratic asked you to adhd a conditional header oregon footer to a papers successful Microsoft Word, would you panic? Some users mightiness due to the fact that the interface offers nary specified option. You tin usage the Different Odd & Even Pages option, but that's not the aforesaid thing. 

A conditional header oregon footer volition display, oregon not, depending connected whether an look returns TRUE oregon FALSE. In this article, I'll amusement you 3 ways to usage fields to make a conditional header oregon footer, though the examples volition each beryllium successful the footer. 

SEE: 83 Excel tips each idiosyncratic should master (TechRepublic)

I'm utilizing Microsoft 365 connected a Windows 10 64-bit system, but you tin usage earlier versions. Word fields person been astir for a agelong time. This nonfiction assumes you person basal Word skills, but adjacent a beginner should beryllium capable to travel the instructions to success. You tin download the objection .docx and .doc files, but I promote you to signifier entering the fields yourself. Word Online doesn't show headers and footers; nor tin you manipulate them. However, they are inactive there, and they volition print.

What's a tract successful Word?

If you're acquainted with Word fields, you're a measurement ahead. If not, they're not hard to use, but the process mightiness consciousness a spot unusual astatine first. Fields are small programs that implicit a circumstantial task, akin to a macro, but you don't request to constitute immoderate code. Everything the tract needs to bash its occupation is already there, but for the accusation you supply. 

You usage fields astir each clip you usage Word, but you conscionable don't recognize it. For instance, erstwhile you usage the interface to show a leafage fig successful the header oregon footer, you're utilizing a field! If you'd similar to spot that astatine work, unfastened a caller papers and participate a leafage fig successful the header. Then, prime the leafage fig and property Alt + F9. Word converts the leafage fig to its underlying { PAGE } field. In this mode, you tin modify the field. Press Alt + F9, which acts arsenic a toggle, again to spot the leafage number. 

The look to show connected past leafage of the Word doc

It's communal to show a antithetic header oregon footer connected the archetypal oregon past leafage of a document. You tin usage the built-in Different First Page enactment to show a antithetic header connected the archetypal page. There's nary specified enactment for the past page; determining the past leafage requires a elemental tract look successful the signifier

{ IF {PAGE} = { NUMPAGES }, "true text" "false text"}

It's casual to decipher: If the existent leafage number, { PAGE } equals the full fig of pages, { NUMPAGES } people "true text". If the 2 leafage numbers don't match, the look prints "false text".

Let's look astatine a speedy illustration utilizing a three-page document:

  1. Open the header oregon footer by double-clicking successful the apical oregon bottommost margin.
  2. Word volition presumption the cursor astatine the near margin, which is fine.
  3. In this adjacent part, we'll beryllium entering the fields manually, which I deliberation is the easiest mode to participate nested fields. To insert a blank field, property Ctrl + F9 and benignant IF. (Case doesn't truly matter.) 
  4. While inactive wrong the If field, property Ctrl + F9 a 2nd clip to participate a blank tract and participate PAGE.
  5. Move the cursor to the close of the closing } quality successful the { PAGE } tract and participate =.
  6. Press Ctrl + F9 a 3rd clip and participate NUMPAGES.
  7. Move the cursor to the close of the closing } quality successful the NUMPAGES tract and participate "Last page" "Not the past page".

Figure A shows the nested fields. Do not participate the {} characters from the keypad; it won't work. You indispensable participate the blank fields utilizing Ctrl + F9 and participate the contented wrong those brackets. Now, prime the full nested tract look and property Alt + F9 to measure the results (Figure A). As you tin see, the past leafage is the existent page. 

Figure A

wordconditionalfooter-a.jpg

  Use a nested tract look to make a conditional header oregon footer.

I've shown you lone 1 mode to participate fields, but determination are different methods. Before we continue, I privation to stock different mode to participate nested fields that you mightiness find easier. You tin benignant the tract name, specified arsenic IF oregon NAME, prime that sanction and property Ctrl + F9. Doing truthful volition person IF oregon NAME to a tract and insert the brackets.  

This elemental look works good until you person unnumbered pages successful your document. For instance, the papers mightiness person a array of contents oregon a rubric leafage that you don't privation successful the leafage count. When this happens, you indispensable find a mode to accommodate those pages. 

SEE: Windows 10: Lists of vocal commands for code designation and dictation (free PDF) (TechRepublic)

If you're excluding lone the archetypal page, usage the Different First Page option. Doing truthful volition inhibit a leafage number, and Word won't see that leafage successful the last leafage count. Excluding different pages mightiness necessitate a conception interruption oregon an look that evaluates those pages. The pursuing look excludes a two-page conception astatine the opening of the papers that's not included successful the full leafage count:

{ IF {PAGE} = { NUMPAGES - 2 } , "Last page" "Not the past page"}

The look is astir the aforesaid arsenic the first, but the -2 constituent subtracts 2, the full fig of pages you privation to exclude from the leafage count. 

If you privation the look to instrumentality nothing, usage the bare drawstring character, "". For example, the pursuing nested tract look volition instrumentality a drawstring connected the past leafage and instrumentality thing connected each different pages:

{ IF {PAGE} = { NUMPAGES } , "" "Not the past page" }

Now let's look astatine a information that seems a spot much complex.

How to specify leafage numbers successful a footer successful Word

What happens erstwhile you person a footer that you privation to people lone connected circumstantial pages? You usage the aforesaid fields to explicit the circumstantial leafage numbers and usage the due existent and mendacious text. Let's accidental that you privation to people a leafage fig lone connected pages 5 and 6?

The occupation lone seems much complex, but successful truth, it's simpler. Instead of a nested expression, usage 2 expressions:

{ If {Page } = "5" "Page 5" "" }

{ If {Page } = "6" "Page 6" "" }

Figure B shows the leafage fig connected leafage 6.

Figure B

wordconditionalfooter-b.jpg

  Use 2 expressions to fulfill the pages 5 and 6 condition.

Both conditions are elemental to fulfill utilizing 2 antithetic expressions alternatively of a nested expression. Now, let's look astatine thing you mightiness deliberation intolerable utilizing fields.

How to show an representation successful a header oregon footer successful Word

If asked if you tin show a conditional representation successful the header oregon footer, you mightiness reply, "No." That's not correct. You dainty an representation the aforesaid arsenic immoderate different substance oregon value. First, you request to insert the representation record into the papers and prevention it arsenic AutoText. Then, you insert the AutoText into the footer oregon header. 

First, let's adhd TechRepublic's logo to the papers arsenic an AutoText element:  

  1. Insert the representation into the assemblage of the papers (not a header oregon footer) arsenic you would immoderate different representation file. 
  2. Select the representation and click the Explore Quick Parts dropdown. 
  3. Choose Save Selection to Quick Parts Gallery.
  4. In the resulting dialog, springiness the representation a name, specified arsenic TRLogo (see Figure C). 
  5. Click OK. 

Figure C

wordconditionalfooter-c-e.jpg

  Name the representation thing meaningful truthful it's casual to recall.

Now that you person the representation arsenic an AutoText point successful the document, you tin insert it into the header arsenic follows: 

  1. Position the cursor successful the header oregon footer wherever you privation it to appear. 
  2. Using Figure D arsenic a guide, participate the { IF } tract up to the archetypal " character. 
  3. Click the Insert tab. 
  4. From the Explore Quick Parts dropdown (Text group), take AutoText. 
  5. Select the representation (Figure E) and click OK. 

Figure F shows the TechRepublic.com logo successful the footer, conditionally; it appears lone connected the past leafage acknowledgment to the conditional tract look shown successful Figure D.

Figure D

wordconditionalfooter-d.jpg

  Enter the tract look up to the logo image. 

Figure E

wordconditionalfooter-e.jpg

  Select TRLogo, the representation AutoText you antecedently added. 

Figure F

wordconditionalfooter-c.jpg

Fields are truthful versatile that you tin adjacent show an representation conditionally.

This instauration to displaying conditional content, including images, successful a document's header oregon footer is conscionable the beginning. You tin usage the pursuing examination operators: =, <>, <=, and >=. You've learned however to nest fields, which is highly useful. However, adjacent erstwhile you could usage a nested expression, you don't ever person to, arsenic shown successful the 2nd example. Remember to ever usage F9 to insert and modify fields. 

Stay tuned

I mentioned earlier that determination are much ways to participate fields than the 1 I worked you done successful the archetypal example. A aboriginal nonfiction volition see each of the ways to participate Word fields. 

Microsoft Weekly Newsletter

Be your company's Microsoft insider by speechmaking these Windows and Office tips, tricks, and cheat sheets. Delivered Mondays and Wednesdays

Sign up today

Also see

Read Entire Article