delete blank pages from mail merged word 2003 document
delete blank pages from mail merged word 2003 document
(OP)
Hi,
I have a 20 page document, each page has an identical layout with a mixture of text and tables.
I am running a mailmerge on the document which works successfully. My problem is that after the mail merge has completed, I am left with about 15 blank pages per record as their is not always data to merge for every page for each record. Does that make sense? I am printing the final document when the mail merge completes but I dont want to print lots of "blank" templates where no data was merged for that record.
Does anyone know of a macro I can run on the mail merged document which will delete the pages where no data was merged to it. To decide if a page is deleted, the condition could be something like
if mergefiled = blank or if particular cell in table is blank,
then delete complete page of document
Any advice would be greatly appreciated.
I have a 20 page document, each page has an identical layout with a mixture of text and tables.
I am running a mailmerge on the document which works successfully. My problem is that after the mail merge has completed, I am left with about 15 blank pages per record as their is not always data to merge for every page for each record. Does that make sense? I am printing the final document when the mail merge completes but I dont want to print lots of "blank" templates where no data was merged for that record.
Does anyone know of a macro I can run on the mail merged document which will delete the pages where no data was merged to it. To decide if a page is deleted, the condition could be something like
if mergefiled = blank or if particular cell in table is blank,
then delete complete page of document
Any advice would be greatly appreciated.
RE: delete blank pages from mail merged word 2003 document
Having:
Is over the top!
Cheers
[MS MVP - Word]
RE: delete blank pages from mail merged word 2003 document
http:/
For cross-posting etiquette, please see: http://www.excelguru.ca/node/7
Cheers
[MS MVP - Word]
RE: delete blank pages from mail merged word 2003 document
None of my other posts had a reply, I have edited my other posts and put a link to this post as the original.
It looks like I have been trying to do this the wrong way. Will read up on IF field tests, thanks.
RE: delete blank pages from mail merged word 2003 document
Your mailmerge description suggests you might have many records per 'letter'. If that's the case, you can use Word's Catalogue/Directory Mailmerge facility (the terminology depends on the Word version). To see how to do so with any mailmerge data source supported by Word, check out my Microsoft Word Catalogue/Directory Mailmerge Tutorial at:
http://lo
or
ht
Do read the tutorial before trying to use the mailmerge document included with it
Cheers
[MS MVP - Word]
RE: delete blank pages from mail merged word 2003 document
Pending your implementation of the IF tests or the Catalogue/Directory mailmerge, here's a macro that will delete all empty table rows from your document:
CODE
Dim oRow As Row, oTable As Table
Application.ScreenUpdating = False
For Each oTable In ActiveDocument.Tables
For Each oRow In oTable.Rows
If Len(Replace(oRow.Range.Text, Chr(13) & Chr(7), _
vbNullString)) = 0 Then oRow.Delete
Next oRow
Next oTable
Application.ScreenUpdating = True
End Sub
Cheers
Paul Edstein
[MS MVP - Word]
RE: delete blank pages from mail merged word 2003 document
RE: delete blank pages from mail merged word 2003 document
From the OP's:
and I get the impression that the so-called blank pages are anything but. At the very least, it seems they have empty table rows and maybe some text as well.
Cheers
Paul Edstein
[MS MVP - Word]
RE: delete blank pages from mail merged word 2003 document
CODE
vbNullString)) = 0 Then oRow.Delete
< 60 working days until retirement