How to insert page numbers in footer of mail merge doc
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
How to insert page numbers in footer of mail merge doc
I have a mail merge document (.docx file) that merges info from an Excel workbook (.xls file). In the footer, I have placed a literal "Printed on" and a field representing the current date. So far, so good.
I would like to insert a simple page number (better yet, page x of y). However, when I insert this into the template from the Word 2010 available footer formats, the first page of the final merged document shows Page 1 of 1 (There are actually 2 pages) and the second page of the final merged document shows Page 1 of 2. I need it to say "1 of 2" and "2 of 2".
What command can I insert into the footer of the template so that "Page X of Y" comes out correctly? Or, do I have to do this in the final merged document?
Thanks, in advance.
I would like to insert a simple page number (better yet, page x of y). However, when I insert this into the template from the Word 2010 available footer formats, the first page of the final merged document shows Page 1 of 1 (There are actually 2 pages) and the second page of the final merged document shows Page 1 of 2. I need it to say "1 of 2" and "2 of 2".
What command can I insert into the footer of the template so that "Page X of Y" comes out correctly? Or, do I have to do this in the final merged document?
Thanks, in advance.
Carol W.
-
- Administrator
- Posts: 78549
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to insert page numbers in footer of mail merge doc
Try print previewing the document, the page numbers should then be correct.
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: How to insert page numbers in footer of mail merge doc
Sorry, Hans. In Print Preview (of the merged document), page 1 says "Page 1 of 2" and page 2 also says "Page 1 of 2".
I even tried just inserting the page number (leaving out the "of x") into the template. Page 1 says 1 and Page 2 also says 1.
I'm using the labels template, if that makes any difference. Any other thoughts?
I even tried just inserting the page number (leaving out the "of x") into the template. Page 1 says 1 and Page 2 also says 1.
I'm using the labels template, if that makes any difference. Any other thoughts?
Carol W.
-
- Administrator
- Posts: 78549
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to insert page numbers in footer of mail merge doc
In a mail merge, each new section is set to restart page numbering at one. In most situations, that would be the desirable setup. You could run a macro after performing the mail merge to make the page numbers continue:
Code: Select all
Sub FooterPageNumbers()
Dim i As Long
For i = 2 To ActiveDocument.Sections.Count
ActiveDocument.Sections(i).Footers(wdHeaderFooterPrimary).PageNumbers.RestartNumberingAtSection = False
Next i
End Sub
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: How to insert page numbers in footer of mail merge doc
Thanks, Hans. The code works. The page numbers are correct after I run the macro.
However, the problem I now have is that everytime the merged file is created it is a new file. I would (personally) have to copy/paste the code that gets the page numbers to be correct every time the merged file is created. I would like this to be as "user friendly" as possible. My users could never handle pasting code into the VBA Editor. Their technical skills are severely limited. They are used to my Access reports where the page numbers automatically come out correct but since my Access database will be "mothballed" (to reduce their dependence on my Access skills), they will need to work with Excel and Word.
Any suggestions on how to make the macro insertion and running more "user friendly"?
However, the problem I now have is that everytime the merged file is created it is a new file. I would (personally) have to copy/paste the code that gets the page numbers to be correct every time the merged file is created. I would like this to be as "user friendly" as possible. My users could never handle pasting code into the VBA Editor. Their technical skills are severely limited. They are used to my Access reports where the page numbers automatically come out correct but since my Access database will be "mothballed" (to reduce their dependence on my Access skills), they will need to work with Excel and Word.
Any suggestions on how to make the macro insertion and running more "user friendly"?
Carol W.
-
- Administrator
- Posts: 78549
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to insert page numbers in footer of mail merge doc
The macro could be copied into the users' default template (Normal.dot or Normal.dotm depending on the version of Word). Or you could create a Word template (.dot or .dotm) with the macro and have it installed in the users' startup folder for Word so that it becomes an add-in. The macro would then always be available; you could make it easy to run by creating a custom toolbar button for it.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: How to insert page numbers in footer of mail merge doc
Hi Carol,
Presumably, you're using a DATE or PRINTDATE field for the date. If you're saving the mailmerge output document, you'll find that both of these will auto-update next time you open/print the document. To prevent that, simply embed a DATE in a QUOTE field (eg {QUOTE {DATE \@ "dddd, d MMMM yyyy"}}) in the mailmerge main document. That will cause the mailmerge process to convert the date to normal text.Carol W. wrote:I have a mail merge document (.docx file) that merges info from an Excel workbook (.xls file). In the footer, I have placed a literal "Printed on" and a field representing the current date.
Assuming your mailmerge main document has only one page, and there is only one record per page, you can simply replace the PAGE field used for the 'X' in the "Page X of Y" numbering with a MERGEREC field.Carol W. wrote:I would like to insert a simple page number (better yet, page x of y). However, when I insert this into the template from the Word 2010 available footer formats, the first page of the final merged document shows Page 1 of 1 (There are actually 2 pages) and the second page of the final merged document shows Page 1 of 2. I need it to say "1 of 2" and "2 of 2".
What command can I insert into the footer of the template so that "Page X of Y" comes out correctly? Or, do I have to do this in the final merged document?
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: How to insert page numbers in footer of mail merge doc
Hans,
I copied your code into a .dotm file and placed that file in the Word 2010 startup folder (on my computer, as a test). It is now available in all Word documents. I decided that approach was safer than putting the code in the Normal.dotm file since that file might be recreated by Word if it ever got corrupted.
Now my problem is how and where to create the button to activate the macro. I know how to do this in Access but have never done it in Word. I see that if I had recorded the macro (which I didn't), I could have assigned a keyboard shortcut to the macro or assigned the macro to a button. Since I didn't record it, how do I assign the already created (by you) macro to a button? I would imagine that the button would be accessible from any Word doc so my users could click it in the completed merged file.
Paul,
Thanks for the reply. My mailmerge main document is one page but it contains eight records so the <<MERGEREC>> field won't work (I tried it just to see how it would work). Also, the date in the footer is behaving the way I want it to but I'll keep your suggestion for that in mind.
I copied your code into a .dotm file and placed that file in the Word 2010 startup folder (on my computer, as a test). It is now available in all Word documents. I decided that approach was safer than putting the code in the Normal.dotm file since that file might be recreated by Word if it ever got corrupted.
Now my problem is how and where to create the button to activate the macro. I know how to do this in Access but have never done it in Word. I see that if I had recorded the macro (which I didn't), I could have assigned a keyboard shortcut to the macro or assigned the macro to a button. Since I didn't record it, how do I assign the already created (by you) macro to a button? I would imagine that the button would be accessible from any Word doc so my users could click it in the completed merged file.
Paul,
Thanks for the reply. My mailmerge main document is one page but it contains eight records so the <<MERGEREC>> field won't work (I tried it just to see how it would work). Also, the date in the footer is behaving the way I want it to but I'll keep your suggestion for that in mind.
Carol W.
-
- Administrator
- Posts: 12617
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: How to insert page numbers in footer of mail merge doc
In Word 2010.
- Select the File tab
- Customize...
- Customize Ribbon
- Keyboard Shortcuts: Customize...
- Select the global template in the "Save Changes in" drop down
- Scroll to the bottom of the Categories list box and select Macros
- Select your Macro in the right hand list box
- Type the keyboard shortcut you want to use in the "Press new shortcut key" box
- OK your way back out again
StuartR
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: How to insert page numbers in footer of mail merge doc
Stuart,
Thanks for the instructions. I chose Alt+P as my shortcut.
For "Save changes in", the default is Normal.dotm. The other choice is Document1. My macro isn't in normal.dotm. I created another .dotm file and put it in the Word 2010 startup folder.
Which dropdown entry should I choose for "Save changes in"? Normal.dotm or Document1?
Thanks.
Thanks for the instructions. I chose Alt+P as my shortcut.
For "Save changes in", the default is Normal.dotm. The other choice is Document1. My macro isn't in normal.dotm. I created another .dotm file and put it in the Word 2010 startup folder.
Which dropdown entry should I choose for "Save changes in"? Normal.dotm or Document1?
Thanks.
Carol W.
-
- Administrator
- Posts: 78549
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: How to insert page numbers in footer of mail merge doc
You should open your add-in .dotm (the one containing the macro). You can then select it as the location to save the keyboard shortcut in.
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: How to insert page numbers in footer of mail merge doc
Hans,
I did as you suggested and it did give me my document name (roster.dotm) as a choice in the "Save changes in" dropdown. I chose it and clicked "Assign".
However, I think I picked the wrong keyboard shortcut. I picked Alt+F and when I pressed it in the merged document, hoping to repaginate the merged document, I got some message about digital signatures. I'm thinking this must be a reserved shortcut.
Any thoughts?
I did as you suggested and it did give me my document name (roster.dotm) as a choice in the "Save changes in" dropdown. I chose it and clicked "Assign".
However, I think I picked the wrong keyboard shortcut. I picked Alt+F and when I pressed it in the merged document, hoping to repaginate the merged document, I got some message about digital signatures. I'm thinking this must be a reserved shortcut.
Any thoughts?
Carol W.
-
- 4StarLounger
- Posts: 508
- Joined: 17 Dec 2010, 03:14
Re: How to insert page numbers in footer of mail merge doc
I take it then, it's a label merge, in which case you can use a SECTION field for the page X numbers.Carol W. wrote:My mailmerge main document is one page but it contains eight records so the <<MERGEREC>> field won't work (I tried it just to see how it would work). Also, the date in the footer is behaving the way I want it to but I'll keep your suggestion for that in mind.
Paul Edstein
[Fmr MS MVP - Word]
[Fmr MS MVP - Word]
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: How to insert page numbers in footer of mail merge doc
Hans,
I changed the keyboard shortcut to alt+ctrl+P and it works now. Thanks.
Paul,
Yes, it's a label merge. Where should I put the SECTION field and what is the syntax? Sorry for the dumb questions but I've never done a complex mail merge like this before. I have done easy ones (without page numbers). Thanks.
I changed the keyboard shortcut to alt+ctrl+P and it works now. Thanks.
Paul,
Yes, it's a label merge. Where should I put the SECTION field and what is the syntax? Sorry for the dumb questions but I've never done a complex mail merge like this before. I have done easy ones (without page numbers). Thanks.
Carol W.
-
- 3StarLounger
- Posts: 235
- Joined: 08 Jun 2010, 20:03
- Location: Morgantown, PA
Re: How to insert page numbers in footer of mail merge doc
Carol,
Maybe you've ealready gotten an answer to this.
Open your footer.
Remove the Page number field.
In its place, choose Insert, Field, and pick Section. Pick the format you want in the dialog box, and click on OK.
You will now have section numbers at the bottom of each page instead of page numbers, and, since your section is one page, the section numbers will be de facto page numbers.
Maybe you've ealready gotten an answer to this.
Open your footer.
Remove the Page number field.
In its place, choose Insert, Field, and pick Section. Pick the format you want in the dialog box, and click on OK.
You will now have section numbers at the bottom of each page instead of page numbers, and, since your section is one page, the section numbers will be de facto page numbers.
Cordially,
Bob Sullivan
Elverson, PA
Bob Sullivan
Elverson, PA
-
- 3StarLounger
- Posts: 390
- Joined: 26 Jan 2010, 16:02
- Location: Las Vegas, NV
Re: How to insert page numbers in footer of mail merge doc
BobSullivan,
Thanks so much! Worked like a charm.
Now I don't have to train my users in the running of macros. The less they have to learn, the better.
Thanks so much! Worked like a charm.
Now I don't have to train my users in the running of macros. The less they have to learn, the better.
Carol W.