BlueCapra

Using Technology To Solve Problems and Create Solutions

  • About Alan Reeves
  • Curiosity & Learning
  • Projects

How-To: Use VisualBasic to Print Mailmerge Documents Separately in Microsoft Word

November 21, 2013 by Alan R Leave a Comment

Have you ever received a newsletter with your name and address printed on the back?  If you have ever wondered what it takes to do that for your organization or business, you are in the right place.  With a little bit of VisualBasic programming and the right equipment, you can save a ton of time and effort.

Several months ago, a co-worker was trying to print a company newsletter on a large Toshiba printer that folds, prints, staples, and possibly makes coffee (it is a very nice machine).  His problem was that every time he did a mail merge to get the names and addresses populated on the newsletter back page, the printer would print all of the several hundred newsletters and try to staple and fold the whole group.  The Toshiba is a nice machine but there was no way it could print over 1000 pages, fold and staple them.  The first 2 or 3 would print, get stapled together, and an error would occur.

Through the magic of VisualBasic programming and macros, we were able to get the desired result.  Here is the code it took to print each one separately:

https://gist.github.com/7404214

You can also see this code on GitHub.  Here is a rundown of the function:

  • Lines 6-8 declare the variables
  • Line 10 sets up the variable to control the loop
  • Line 11 makes sure the mail merge starts at the beginning
  • Lines 13-30 is the loop that steps through the mail merge records
  • Lines 15-17 sets up the file name if you are going to save the files (not necessary if you are only going to print)
  • Line 20 saves the files if needed
  • Line 26 prints the document
  • and Line 28 moves to the next mail merge record

In your situation, you may need to adjust a few lines of code but if your mail merge is setup right, it should work.

If you have a chance to use this macro, leave me a comment and let me know how it works for you.

Filed Under: How-To

Leave a Reply Cancel reply

You must be logged in to post a comment.

Find what you are looking for

Books I've Read

48 Days to the Work You Love
Being Wrong: Adventures in the Margin of Error
How Doctors Think
The Art of Possibility: Transforming Professional and Personal Life
Dirty Rotten Strategies: How We Trick Ourselves and Others into Solving the Wrong Problems Precisely
Brainstorm: Harnessing the Power of Productive Obsessions
The Creative Habit: Learn It and Use It for Life
A Book of Five Rings: The Classic Guide to Strategy
Wild at Heart: Discovering the Secret of a Man's Soul
Reality Check: The Irreverent Guide to Outsmarting, Outmanaging, and Outmarketing Your Competition
Startup Guide to Guerrilla Marketing: A Simple Battle Plan For Boosting Profits
Vagabonding: An Uncommon Guide to the Art of Long-Term World Travel
Seeking Wisdom: From Darwin To Munger
Multiple Streams of Internet Income: How Ordinary People Make Extraordinary Money Online
Thomas Paine: Enlightenment, Revolution, and the Birth of Modern Nations
The War of Art: Break Through the Blocks & Win Your Inner Creative Battles
The 4-Hour Workweek: Escape 9-5, Live Anywhere, and Join the New Rich
Where Good Ideas Come From: The Natural History of Innovation
Moonwalking with Einstein: The Art and Science of Remembering Everything
Build Your Own Wicked Wordpress Themes


Alan Reeves's favorite books »

Copyright © 2025  ·  BlueCapra.com  ·  Built on the Genesis Framework and Centric child theme   ·  Affiliate Disclosure

Copyright © 2025 · Centric Theme on Genesis Framework · WordPress · Log in