headers / sections in word 2k

I write modules for the class I teach.  I would like to have a header for each activity that says "Activity 1" on the first page and if it spills over to another page it says "Activity 1 - Continued".


Who is Participating?
NoggyConnect With a Mentor Commented:
megamike - I got your file. All I can say is "oops". I seem to have got my logic a tiny bit wrong. It must have been from when I was testing it out.

I have amended the field codes so that they work OK:
1. Where we had ">", there should have been "<=".
2. The "/p" should have been "\p" instead.
3. The "{PAGEREF /p I}" should have been "{PAGEREF \# "0" \p  I}". This one's a bit weird as the former was returning the correct result e.g. "4". But, when breaking down the codes this time, it was returning "on page 4". So any numeric value would never be greater than a text value.

I'm returning your doc back to you. You will find that I have added a new bookmark for your Introduction heading; I have called this "Intro". My Word seems to get a bit picky over 1 character bookmarks.

So, what I did was to copy each of the individual field codes from the {If...} bookmark onto separate lines so that I could check what each of the resulting conditions would be. This is the only way that I know of to debug these things.

I also noticed that amending any of the field codes also meant that I had to select the whole field code and press F9 to refresh it. Otherwise, when I changed the bookmark reference, I was finding that the field code result would be "Error: Bookmark Not Defined". The F9 refresh would correct this though.

So, instead of:
{if {PAGE} > {PAGEREF /p I} {REF I \*MERGEFORMAT } "{REF I \*MERGEFORMAT } - Continued "}
you now have:
{if {PAGE} > {PAGEREF \# "0" \p Intro } {REF Intro \*MERGEFORMAT } "{REF Intro \*MERGEFORMAT } - Continued "}

As I said earlier, if they do not seem to be working correctly, just break out the individual parts of the field code formula like I have done in your document. So, you'll see in your doc that instead of:
{if {PAGE} > {PAGEREF \# "0" \p Intro } {REF Intro \*MERGEFORMAT } "{REF Intro \*MERGEFORMAT } - Continued "}
you now have:
{if {PAGE} > {PAGEREF \# "0" \p Intro } {REF Intro \*MERGEFORMAT } "{REF Intro \*MERGEFORMAT } - Continued "}
{PAGE} > {PAGEREF \# "0" \p Intro }
"{REF Intro \*MERGEFORMAT } - Continued "
That way, as I said (again :-) ), you can debug the things.

Again, apologies for the typos. I guess that it must have been a late night that night and errors were creeping in. It's just a shame that you can't actually copy the field code directly into EE as plain text without the damn things being evaluated in Word first (i.e. as you are probably aware, you have to type the things out practically manually in EE).

I hope that this resolves your problems.
I assume you will have one Word document per teaching module. Do the following:

Open template or document you use as 'mastercopy' for editing your teaching  module

a) File|PageSetup|Layout: Header&Footer Different First Page

b) In document make a page break with Ctrl+Enter

c) Change to View|PageLayout, go to first page

d) Change to View|HeaderAndFooter

e) In header field of 'FirstPage':
- Insert|Field|DocumentInformation: FileName (incl. Options for formatting)
- Eventually add some additional fixed text

f) In header field of the next page:
- Repeat insert of Filename
- Add '- Continued' (w/o ') after FileName field

g) Optional: Delete the ....Page Break.... _marker_ (press Pi Symbol to reveal it). The header of the following pages will reappear¨as defined in f) the moment your text has more than one page, let Microsoft explain this.


1) Save New Document (or Save As) with wanted name of teaching module.

2) Do your editing

3) If g) was not not deleted: Remember to delete extra page if no overflow.
megamikeAuthor Commented:
Adjusted points from 50 to 100
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

megamikeAuthor Commented:
I am working through your example right now.  I think it is close to what I need and I may be able to get there with your tip.  The one point that I believe is different is that my modules are all 1 document.  The format would look like this

Cover Page
Introduction and Objectives
Activity 1 (3 pages)
Activity 2 (2 pages)
Activity 3 (4 pages)

Thanks and I will keep experimenting
Well, I should have stated "pre-requisite", not "assume" that you have one document per module. You might combine the partial documents with the 'Binder', but this could create other problems.

For your wanted 'all-in-one' you must use sections to be able to define different headers. However, forget the fully automatic convenience, i.e. _you_ must define the text for each header _and_ ensure the correct the pagination. Maybe it could be programmed in VBA/Word, but I am not sure whether is would be easier to handle.

Consider whether this simplification is acceptable for you:

a) Define one section per chapter: (Insert|Break|Section: Next Page)

b) Start an Activity on a fresh page, manually (Ctrl+Enter) or automatically, by defining the Style of the used heading this way.

c) When editing the header and footers per section make sure the button "as previous" is not pressed.  

d) Instead of '- Continued' insert the following numbering scheme:
- Insert|PageNumber: Format: Start at 1 (i.e. _not_ continuous)
- Add 'of' or "/", then use Insert|Field|Numbering SectionPages to automatically get the total number of page for each section.
megamikeAuthor Commented:
hmm.  Will give that a try.  Thanks.
megamike, here's an article that you can adapt to do what you want:
WD97: Use Field to Print Text in Footer Except on Last Page - http://support.microsoft.com/support/kb/articles/Q192/3/18.ASP

I've had a go and this is how I solved it:
1. For each of your Activity Headings, select the heading and create a bookmark of it.
2. Put a section break before each of those headings too.
3. In each of the sections, in the header, enter the following (using the doclink above as a guide):

{ If {page} > {PAGEREF /p ActivityHeading1}<Space>{REF ActivityHeading1 \*MERGEFORMAT}<Space>"{REF ActivityHeading1 \*MERGEFORMAT} - Continued"}

ActivityHeading1 is the bookmark name for that heading.
<Space> denotes you have to put a space character in there i.e. " " (and not "<Space>")

I can't think of an easier way to do this I'm afraid.

<I can't think of an easier way to do this I'm afraid.>

Well, not sure if the "- Continued" is worth the additional hassle with bookmarks and conditional fields. As an activity can have more than 2 pages a numbering like "Activity1 - Page 1/4" contains more information. But obviously this is for megamike to decide.    

megamikeAuthor Commented:
Struggled with it for a while yesterday... Will play with both ideas again tonight during the Wings game.  Thanks for the tips.  
megamikeAuthor Commented:
Adjusted points from 100 to 150
megamikeAuthor Commented:
I agree that this is a lot of hassle.  Sure appreciate your time.
megamikeAuthor Commented:
Alright, trying the code version because I really like the - continued

Not a ton of luck though.

I bookmarked a couple of activites as Activity_1 and Activity_2 respectively.

Using your tips I changed your If statment to the following...

{IF  page>PAGEREF/p Activity_1 REF Activity_1 \*MERGEFORMAT "REF Activity_1\*MERGEFORMAT - Continued" \* MERGEFORMAT \* MERGEFORMAT }

All the pages say activity_1...  I missed something, can you help me find it.

Yeah, you missed out some curly braces:
What I had:
{ If {page} > {PAGEREF /p ActivityHeading1}<Space>{REF ActivityHeading1 \*MERGEFORMAT}<Space>"{REF ActivityHeading1 \*MERGEFORMAT} - Continued"}

What you had:
{IF  page>PAGEREF/p Activity_1 REF Activity_1 \*MERGEFORMAT "REF Activity_1\*MERGEFORMAT - Continued" \* MERGEFORMAT \*MERGEFORMAT }

What you should have:
{ If {page} > {PAGEREF /p Activity_1 }<Space>{REF Activity_1  \*MERGEFORMAT}<Space>"{REF Activity_1  \*MERGEFORMAT} - Continued"}

Please ensure that you put in all the curly braces (i.e. "{" & "}") using Ctrl+F9.
megamikeAuthor Commented:
I bet a large part of the problem was the Ctrl+F9.  I had pasted the braces in earlier and kept getting errors.  When I biffed the braces I at least got some output so I thought I was on the correct track. =)  

Will use the Ctrl now.

Aha, your last comment tells me that you didn't read the MS doclink article that I provided, you naught person :-) . The Ctrl+F9 thing was in there.

So, have you got it working? Also bear in mind cri's suggestion as it is always better to provide as much information to the users as possible. I will have a look at providing the solution myself but it won't be until later - because I've got to go to the pub now :-) .
megamikeAuthor Commented:
I bet a large part of the problem was the Ctrl+F9.  I had pasted the braces in earlier and kept getting errors.  When I biffed the braces I at least got some output so I thought I was on the correct track. =)  

Will use the Ctrl now.

megamikeAuthor Commented:
Alright...  Back from break, but still fighting this. =)  Not quit in me though...

Used CTRL+F9  Works nice.  Re-read the MS KB article.  

I have created bookmarks for the following
Activity_1 (Is there any way to have a space not an underscore?)

I have put section breaks in front of (before) each of them.

I have typed in the formula using Ctrl+F9...

I added the page numbers to the footer to help me see where I was.

I beleive I have to type the header formula in each section according to the bookmark name.

I cannot get the first page to not say -continued.

I need to know what PAGEREF /p, REF and \*MERGEFORMAT do. (maybe I don't, =], but it might clear things up for me.

I also have to have the
No, you can't have spaces in bookmark names. I only used underscores so that it was easier to see which bookmark was which. I would normally not use an unserscore but just use "Activity1". It's only a bookmark so there's no problem there.

Yes, you do have to type the header formula in each section according to the bookmark name. This could be automated though, I suppose.

Why would you want the first page to say "Continued"? The idea of the first page is that it is the first page of that section. It is only on the second page onwards that you will want "Continued".

Or do you want it on the first page in the footer to say that the section continues onto the next page (and not on the last page)? In which case, I would think you would want "Continues"?

To understand what each of the field codes do, look in the Word Help. Below are extracts from it:

Field codes: PageRef field

{ PAGEREF Bookmark [\* Format Switch ] }
Inserts the page number of a bookmark for a cross-reference. To cross-reference items in a document, use the Cross-reference command (Insert menu).

Switch      Explanation
\* Format Switch       Optional switch that overrides the numeral style selected in the Page Number box in the Page Number Format dialog box (Page Numbers command, Insert menu). For more information, click  .
\h      Creates a hyperlink to the bookmarked paragraph.
\p      Causes the field to display its position relative to the source bookmark.The string "on page #" is used when the PAGEREF field is not on the current page. When the PAGEREF field is on the current page, it omits "on page #" and returns "above" or "below" only.

In the following example, the bookmark "Worldpop1990" marks the table containing figures for 1990.


The world population in 1991 was 5 billion; for 1990 figures, see the table { PAGEREF Worldpop1990 \p }.


The number of the page on which the table appears is inserted in place of the field:
"... see the table above."

Field codes: Bookmark and Ref fields

{ [REF] Bookmark [Switches ] }
Inserts the text or graphics represented by the specified bookmark. The bookmark must be defined in the active document. To insert bookmarked text or graphics from another document, use the INCLUDEPICTURE or INCLUDETEXT field. The Cross-reference command (Insert menu) inserts REF fields to create cross-references.
The BOOKMARK field is an abbreviated form of the REF field and isn't available in the Field dialog box (Insert menu). If a bookmark name (for example, "Title") matches a Word field name (TITLE), you must use the REF field. The field { REF Title } inserts the text represented by the "Title" bookmark, whereas the field { Title } inserts the contents of the Title box on the Summary tab in the Properties dialog box (File menu).

Note   When you insert text copied from another location in the same document, the Paste Special command (Edit menu) inserts a REF field with the bookmark INTER_LINKn, where n is incremented automatically. You should not edit an INTER_LINKn bookmark in a REF field. Also note that REF fields with INTER_LINKn bookmarks in a mail merge main document can cause errors during merging.

Instruction      Explanation
Bookmark      The name of a bookmark. If the text marked by the bookmark contains a paragraph mark (), the text preceding the BOOKMARK field assumes the formatting of the paragraph in the bookmark.
\f      Increments footnote, endnote, or annotation numbers that are marked by the bookmark and inserts the corresponding note or comment text. For example, the bookmark "Note1" marks the reference mark of footnote 1. The field { REF Note1 \f } is inserted after footnote 2. The field result displays the footnote reference mark "3" in the document text and inserts the text of footnote 1 into the footnote window.
\h      Creates a hyperlink to the bookmarked paragraph.
\n      Causes the field to display the entire paragraph number for a referenced paragraph without trailing periods. No information about prior levels is displayed unless it is included as part of the current level.
\p      Causes the field to display its position relative to the source bookmark using the word "above" or "below."7      If the REF field appears in the document before the bookmark, it evaluates to "below."7      If the REF field appears after the bookmark, it evaluates to "above."7      If the REF field appears within the bookmark, an error is returned.7      This switch can also be used in conjunction with the \n, \r, and \w switches. When this is done, "above" or "below" is appended to the end of the field result.
\r      Inserts the entire paragraph number of the bookmarked paragraph in relative context > or relative to its position in the numbering scheme > without trailing periods.
\t      Causes the REF field to suppress non-delimiter or non-numerical text when used in conjunction with the \n, \r, or \w switches.With this switch, for example, you can reference "Section 1.01," and only "1.01" is displayed in the result.
\w      Inserts the paragraph number of the bookmarked paragraph in full context from anywhere in the document.For example, when referencing paragraph "ii.," a REF field with the \w switch would return "1.a.ii" as a result.

The following REF field assigns the result of an ASK field that prompts the user for the cost per unit. The ASK field prompts the user for information when the field is updated and then assigns the user's input to the bookmark "unitcost":

{ ASK unitcost "What's the cost per unit?" }

The following REF field's result will display the user's input:

{ REF unitcost }

Format (\*) field switch

Specifies how to display field results. The format instructions determine the use of uppercase and lowercase letters; number formats > for example, whether "9" is displayed as "ix" (roman numerals) or "ninth" (ordinal text); and character formats. Format switches also retain a field result's formatting when the field is updated.

What do you want to know more about?

Capitalization formats
      Number formats
      Character formats and protecting previously applied formats

Capitalization formats

This switch      Capitalizes
\* Caps      The first letter of each word. For example,
{ FILLIN "Type your name:" \* Caps } displays "Julie Tanner" even if the name is typed in lowercase letters.
\* FirstCap      The first letter of the first word. For example,
{ COMMENT \* FirstCap } displays "Weekly report on sales".
\* Upper      All letters. For example, { QUOTE "word" \* Upper } displays "WORD".
\* Lower      None of the result; all letters are lowercase. For example, { FILENAME \* Lower } displays "weekly sales report.doc".Note   This switch has no effect if the entire field that contains the switch is formatted as small capital letters.

Number formats

This switch      Displays numbers as
\* alphabetic      Alphabetic characters. The result has the same case as the word "alphabetic" in the field code. For example, { SEQ appendix \* ALPHABETIC } displays "B" (instead of "2"), and
{ SEQ appendix \* alphabetic } displays "b".
\* Arabic      Arabic cardinal numerals. For example,
{ PAGE \* Arabic } displays "31".Note   If the Number format setting in the Page number format dialog box (Page numbers command, Insert menu) is not arabic, this switch overrides the Number Format setting.
\* CardText      Cardinal text. The result is formatted in lowercase letters unless you add a format switch to specify a different capitalization. For example,
{ = SUM(A1:B2) \* CardText } displays "seven hundred ninety", and
{ = SUM(A1:B2) \* CardText \* Caps } displays "Seven Hundred Ninety".
\* DollarText      Cardinal text. Word inserts "and" at the decimal place and displays the first two decimals (rounded) as arabic numerators over 100. The result is formatted in lowercase letters unless you add a format switch to specify a different capitalization. For example,
{ = 9.20 + 5.35 \* DollarText \* Upper } displays
"FOURTEEN and 55/100".
\* Hex      Hexadecimal numbers. For example,
{ QUOTE "458" \* Hex } displays "1CA".
\* OrdText      Ordinal text. The result is formatted in lowercase letters unless you add a format switch to specify a different capitalization. For example, { DATE \@ "d" \* OrdText } displays "twenty-first", and
{ DATE \@ "d" \* OrdText \* FirstCap } displays
\* Ordinal      Ordinal arabic text. For example,
{ DATE \@ "d" \* Ordinal } displays "30th".
\* roman      Roman numerals. The result has the same case as the word "roman" in the field code. For example,
{ SEQ CHAPTER \* roman } displays "xi", and
{ SEQ CHAPTER \* ROMAN } displays "XI".

Character formats and previously applied formats

This switch      Applies
\* Charformat      The formatting of the first letter of the field type to the entire result. The result of the following example has bold formatting because the "R" in "REF" is bold.{ REF chapter2_title \* Charformat } displays "Whales of the Pacific".Note   To add this switch, type it in the field code or in the Field Codes box in the Field dialog box (Insert menu, Field command).
\* MERGEFORMAT      The formatting of the previous result to the new result. For example, if you select the name displayed by the field
{ AUTHOR \* MERGEFORMAT } and apply bold formatting, Word retains the bold formatting when the field is updated when the author name changes
megamikeAuthor Commented:
Adjusted points from 150 to 200
megamikeAuthor Commented:
GRRR! =)   Thought I had a breakthrough!  

Do I need the formula in the header of the first page of each section, or just the following pages each section?

You state correctly that I do not want -continued on the first page.  Problem was, that is what I keep receiving...

You are right that the underscore does not matter.  I had thought I was receiving the underscore in my outputed header, but it is the bookmark.

Check that you have the following at the end of the field formula (just before the last "}"):

"{REF Activity_1  \*MERGEFORMAT} - Continued"

ensuring that the quotation marks are there. I expect (though I doubt) that you may have the "- Continued" outside the curly braces.

If you are sure that the above is correct, then ensure that the field formula starts with:

If {page} >

ensuring that {page} is in curly braces.

Otherwise, the formula should be working fine. Basically, one end of the formula or the other is not working correctly.

If that fails, you can email me the doc at: Noggy@email-lotto.com
However, if you do that, let me know by means of a comment in EE as I rarely check that email address.
Sorry, but I can not help to quote myself: "...Well, not sure if the '- Continued' is worth the additional hassle with bookmarks and conditional fields..."
megamikeAuthor Commented:
Have asked myself that too, but like a pit bull, I am persistant.  I feel like I am close to being on to something here too.
Trouble with persistance is the perspiration...
I find the same happens with saunas :-) .
megamikeAuthor Commented:
Adjusted points from 200 to 250
megamikeAuthor Commented:
I have tried again and again and there is somethign funny going on.  If you are still willing I will ship it to you.

For simplicity sake I now have the sections named I for introduction (caps, not sure why) and a1 and a2 for activity 1 and 2 respectively.

I have only put in the first formula this time.  It returned the Bookmark does not exist error.

I will expand the document, if you will just get me past the hurdle.

Thanks again!
Yeah, send it to me, megamike. I'll have a look at it.

Email me the doc at: Noggy@email-lotto.com and let me know by means of a comment here that you've sent it me.
megamikeAuthor Commented:
Tis there I believe.

megamikeAuthor Commented:
Thanks for hanging in there with me Noggy!  I had fiddled with the >= idea when I was tinkering, but of course it did not matter beacuse the of the field refresh you mention.

I also appreciate the tip for debugging.  It is little ideas like that, that slip by when someone is trying to learn stuff.  I appreciate it.

Thanks again for your persistance.  I can relate to the late night nature of these things. =)

You're totally welcome, megamike. Cheers, for the grade and the points.

It was a bit of an eye-opener for me too. I rarely use formulae like that in my docs (in fact, I don't think I ever have). I just use the simple ones - and they don't seem to cause such problems.

That's the beauty with EE: you are always wanting to expand your skills (or revisit old ones) but you need something practical to try them on. There always seems to be questions in EE that fulfil this need. So, thanks for your q :-) .

As to late nights, that seems to be the only time that I can get to answer q's when the likes of ture, antrat, cri et al are not around :-) .

Thanks again and good luck.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.