×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

delete blank pages from mail merged word 2003 document

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.

RE: delete blank pages from mail merged word 2003 document

Quote:

Does that make sense?
No, it doesn't - the mailmerge should be designed to not generate empty pages. You should be able to do this using 'IF' field tests.

Having:

Quote:

15 blank pages per record
Is over the top!


Cheers
[MS MVP - Word]

RE: delete blank pages from mail merged word 2003 document

(OP)
Thanks for pointing me to the cross post link. Apologies, I can now see that it can be annoying!  I was pretty desperate for an answer so posted to a few different groups.
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

hi bluesea2,

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://lounge.windowssecrets.com/index.php?showtopic=731107
or
http://www.gmayor.com/Zips/Catalogue%20Mailmerge.zip
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

Hi Bluesea2,

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

Sub TableCleaner()
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

You can also get rid of blank pages without a macro, provided that they are based on 'manual page breaks'.  In your standard find / replace function, change ^m^m to ^m.  Run several times to get rid of all such cases.  

yinyang Madawc Williams (East Anglia, UK).  Using Crystal 11.5 with SQL and Windows XP yinyang  

RE: delete blank pages from mail merged word 2003 document

Hi Madawc,

From the OP's:

Quote:

each page has an identical layout with a mixture of text and tables
and

Quote:

if mergefiled = blank or if particular cell in table is blank,then delete complete page of document
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

    If Len(Replace(oRow.Range.Text, Chr(13) & Chr(7), _
      vbNullString)) = 0 Then oRow.Delete
Nice.

< 60 working days until retirement

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close