Monday, September 26, 2011

Setting Up a Book Template Part 15

In the last book-related post, I said we'd look at adding a StyleRef field code to automate chapter titles in headings. If you added the last StyleRef field, you should have an idea of how we're going to do this task.

Replacing Introduction with Introduction
  1. Open your saved document Genealogy Book document. 
  2. Scroll to the third page of the Introduction section (page 15/30). 
  3. Double-click in the header area to open the header. 
  4. Double-click the word Introduction
  5. Display the Field dialog. For Word 2003, select: Insert, Field. For Word 2007/2010, select Insert, Quick Parts (Text group), Field.
  6. In Field names, locate and select StyleRef. The field Properties updates, showing the Style name field with a list of all styles used in your document. 
  7. In Style name, locate and select Heading 1. Introduction should replace the typed Introduction
  8. Click anywhere in Introduction and you'll find that Word adds gray fill because what remains is a field code. 
  9. Save your document. Later, we'll save it as a template and replace your current template.
Updating the Remainder of the Document
  1. Scroll to the third page of chapter one (page 19/30). 
  2. Triple-click the words Chapter 1: The First Generations, and then click Delete to remove the text. 
  3. Link to the previous header. In Word 2003, on the View menu, click Header and Footer, and then Link to Previous. In Word 2007/2010, click the Header & Footer Tools Design tab, locate the Navigation group, and click Link to Previous. A confirmation message appears.
  4. Select Yes. The text Chapter 1: The First Generations appears again. The difference is this time it's an automated field code. If you click anywhere in the text, Word adds a gray background to tell you that it's a field code.
  5. Save your document. 
  6. Repeat these instruction for each section you have in your document. Remember that section is the four-pages that appear between section breaks. 
Seeing the Field Code
  1. Hold down the Alt ky and press F9. The field code replaces the text:
    {STYLEREF "Heading 1" \* MERGEFORMAT}
  2. Hold down the Alt ky and press F9. Text replaces the field code. 
Seeing Why It Matters
  1. Go to any chapter title and change it. It doesn't matter how you change it. 
  2. Go look at the third page of the section. Your heading text updates automatically. 
Background Info
With the addition of field codes, the chapter titles you entered when creating the template truly are just place holders for the chapter titles you really want. You can update them as you write and never have to worry about what is happening in the headers because StyleRef has your back.

One caution: Use the Heading 1 style only for chapter titles. When Word executes the StyleRef field code, it looks for the first available Heading 1 above. If you add text using a Heading 1 style between your chapter title and the StyleRef field code, Word will place that intervening text in the header. 

That being said, you should be coming up with all sorts of uses for StyleRef. For example, how many times is an author's name mentioned in a document? If you create a style named Author, and then apply the style to the first instance of the author's name, you can StyleRef any subsequent mention of the author's name...including any special marks...spelled correctly...assuming you spelled it correctly the first time. And if you misspelled it the first time? Just correct the first instance, and all the StyleRefs are auto updated. 

One of the most counter intuitive aspects of Word is generally speaking it applies to what is above it, and not below it. For this reason, when something goes wrong in a document, you start fixing the problem from the end of the document working your way toward the beginning of the document. This idea doesn't always work but it works in enough circumstances that the idea is worth remembering. 

Next Post
We'll take your updated document (with the field codes) and save it so that it replaces your old template.

No comments:

Post a Comment