#1
|
|||
|
|||
Mail merged document and page numbers for table of contents
Hi there
I hope someone can help me? I needed the same table repeated about 150 times with just one heading changed (in brief, I'm a medical student, and need a table that says description, cause, symptoms, treatment etc for every condition I need to learn). I did a 'letters' mail merge to create a document that had this and it worked perfectly -- almost: I do indeed have the same table 150 times with only the condition name changed. However, I added a table of contents, and I see that every page, from the first to the last, is 'page 1', which makes sense, given that this is the intended use of the letters mail merge option. Is there a way to change this so that it now sees my document not as many individual documents, but as one long document, so the page numbers act as normal? Thanks for your help. JB |
#2
|
||||
|
||||
You can fix that with a Find/Replace, where:
Find = ^12 Replace = ^12 Although the find & replace expressions are the same, this will convert all the Section breaks inserted by the merge into page breaks.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks for your reply. Sadly, I seem to be having 2 problems with this:
1. The find and replace seems to just be removing the breaks, so the tables are now not on separate pages but joined, following on one from the next. 2. Replace all does not work, so I have to click Replace 100s of times to work it. Is this a problem with it being on Word for Mac? BW JB |
#4
|
||||
|
||||
Your profile indicates you're using Office 2010, not Word for Mac! Regardless, the Find/Replace won't of itself cause the tables to join. If that's happening, it suggests your tables have the 'around' wrap format. Setting the wrap format to 'None' should resolve that issue.
As for 'Replace all' not working, it does on a PC and I see no reason why it shouldn't on a Mac. Changing the table wrap format may resolve that issue too.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Yes, sorry, I have changed OS since last posting!
I've given what you said a try, but sadly still no success =( . Would I be able to email it over to you and see if you can get it to work -- would that be okay? BW JB |
#6
|
||||
|
||||
Another option you might consider for the numbering is to use a SECTION field instead of a PAGE field for the numbering. It will provide the same results as you want from a PAGE field if each Section consists of a single page.
If you want someone to take a look at your mailmerge output document, you could attach it to a post, via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Many thanks. Here is the document, if anyone has any success I'd be massively grateful.
EDIT: The file was too big, I'll try to reduce it. BW JB |
#8
|
||||
|
||||
There's still no attachment, but you might try running the following macro on your mailmerge output document:
Code:
Sub Reformat() Application.ScreenUpdating = False Dim HdFt As HeaderFooter, Rng As Range With ActiveDocument If .Sections.Count > 1 Then For Each HdFt In .Sections(.Sections.Count).Headers If HdFt.Exists Then HdFt.Range.FormattedText = .Sections(1).Headers(HdFt.Index).Range.FormattedText HdFt.Range.Characters.Last.Delete End If Next For Each HdFt In .Sections(.Sections.Count).Footers If HdFt.Exists Then HdFt.Range.FormattedText = .Sections(1).Footers(HdFt.Index).Range.FormattedText HdFt.Range.Characters.Last.Delete End If Next End If Do While .Sections.Count > 1 Set Rng = .Sections(1).Range.Characters.Last Rng.Delete Rng.InsertBreak Type:=wdPageBreak DoEvents Loop .Range.Characters.Last.Delete End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Thanks for your reply. Unfortunately it seems my document is too big to post here.
I've tried the macro, but it says "Run-time error '5937': Cannot copy content between these two ranges" When I debug it, it highlights this line: HdFt.Range.FormattedText = .Sections(1).Headers(HdFt.Index).Range.FormattedTe xt Any thoughts? |
#10
|
||||
|
||||
Try:
Code:
Sub Reformat() Application.ScreenUpdating = False Dim HdFt As HeaderFooter, Rng As Range With ActiveDocument If .Sections.Count > 1 Then For Each HdFt In .Sections(.Sections.Count).Headers If HdFt.Exists Then If Len(.Sections(1).Headers(HdFt.Index).Range) > 1 Then HdFt.Range.FormattedText = .Sections(1).Headers(HdFt.Index).Range.FormattedText HdFt.Range.Characters.Last.Delete End If End If Next For Each HdFt In .Sections(.Sections.Count).Footers If HdFt.Exists Then If Len(.Sections(1).Footers(HdFt.Index).Range) > 1 Then HdFt.Range.FormattedText = .Sections(1).Footers(HdFt.Index).Range.FormattedText HdFt.Range.Characters.Last.Delete End If End If Next End If Do While .Sections.Count > 1 Set Rng = .Sections(1).Range.Characters.Last Rng.Delete Rng.InsertBreak Type:=wdPageBreak DoEvents Loop .Range.Characters.Last.Delete End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
It got further this time!
Run-time error 4605: This method or property is not available because the current selection is outside of a block-level XML element. Debug highlights: Rng.InsertBreak Type:=wdPageBreak |
#12
|
||||
|
||||
Without seeing whatever part of your document the code is failing at, I'm not in a position to address whatever the issue is - it's not something that I've encountered in my test files.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#13
|
|||
|
|||
Can I email it to you? Even splitting it in half it is too big to upload here.
|
#14
|
||||
|
||||
I only need a few pages, including the ones either side of the problem. Identifying them requires nothing more than finding the first Section break remaining in the document after the macro crashes.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#15
|
|||
|
|||
Okay, here you go.
J |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Cannot Update Page Numbers Only on Table of Contents | CrossReach | Word | 8 | 03-09-2016 01:18 PM |
Table of Contents - page numbers not aligned to the right in longer headings | krneki | Word | 3 | 08-17-2015 08:34 AM |
Align Mail Merged Numbers to the Decimal Point | HangMan | Mail Merge | 1 | 12-11-2013 02:32 PM |
Page Numbers in Table of Contents | MerRob54 | Word | 6 | 01-28-2013 03:37 AM |
decimal numbers not appearing properly in merged document | paulys | Mail Merge | 2 | 08-06-2012 08:15 AM |