?
Solved

Word Envelope printing macro - loop through document

Posted on 2008-11-09
9
Medium Priority
?
565 Views
Last Modified: 2012-05-05
Hi..
I have a multiple page document with an Name and Address on every page or everyother page.
I need help on  a macro that will loop through the documet and use the MS Word built in Envelope feature and print envlopes for the addresses on every page.
0
Comment
Question by:JElster
  • 5
  • 4
9 Comments
 
LVL 21

Expert Comment

by:Eric Fletcher
ID: 22921416
If your document is only addresses, you could just set the page dimensions for an envelope and print it all. Your return address could then be a header for every page.

If there is other content, is it easily distinguished from the address information? (by style, a code, format, etc.)
0
 
LVL 1

Author Comment

by:JElster
ID: 22921447
The document  looks something like this..  It begins with the address... Can I add some code to distinguish the address and run a macro to create Envelopes.. thx

George Washington
1600 Penn Ave
Wash DC

Dear George

BODY

0
 
LVL 21

Expert Comment

by:Eric Fletcher
ID: 22921816
If the address lines can be uniquely identified, the task is a lot easier -- and you may be able to do it without a macro. by far the easiest and most effective way to identify structural elements is to apply styles.

For example, say the address lines use the style "address" and everything else has other styles. If you selected everything and set the font attribute to hidden, then used Find and Replace to change style=address to font=not hidden, then only the addresses would be visible. You could then print the document on envelope stock as I suggested above. You could record the procedure to make a simple macro to do this (and I would recommend you end it by closing the file without saving it so you retain your original formatting.

You could make it more sophisticated by just redefining styles, and of course you could write code to go through and build a new file of envelopes as you've asked. However, you will have to determine how repeatable this will be and how much effort you want to invest to do it.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
LVL 1

Author Comment

by:JElster
ID: 22921916
hi..
I need to print envelopes directly from the document - I don't need to modify or save the document...
just print envelopes from the document 'data'.   If I use styles on the address how can I grab all the address and print them using the envlope feature.. thanks again
0
 
LVL 21

Accepted Solution

by:
Eric Fletcher earned 1400 total points
ID: 22922280
Take a look at the two documents I have attached. One is a mockup of what I assume you have with the addresses set in a style called "address"; the other is a mockup to print on a #10 envelope. In it, the styles are defined slightly differently but with the same address style name.

To get all the addresses and print envelopes from the eeLetters.doc file, open the Find dialog (Ctrl-F). Click the More button so you can choose Format, Style=address for the Find what box. Click the checkbox to Highlight all items found in=Main Document. When you click Find All, just the address lines will be selected. Close the Find dialog and use Ctrl-C to copy. Now switch to the blank eeEnvelopes.doc document and paste (Ctrl-V). The copied addresses and the page breaks that precede each one will make an envelope for each of your letters. As you will see, I have set up a page header to contain a return address.

Note that I am assuming that your first address line includes the new page break (Ctrl-Enter) as in my eeLetters.doc example file. If not, you will need to modify the procedure a bit to be able to differentiate between the different addresses. Hopefully this will give you a start on it.

eeLetters.doc
eeEnvelopes.doc
0
 
LVL 1

Author Comment

by:JElster
ID: 22925072
Thanks..
How can I automate this into a single macro that I can place on the eeLetters.doc ?
How did you 'assign' the address area style?
0
 
LVL 21

Expert Comment

by:Eric Fletcher
ID: 22926582
Recording the steps doesn't record the "Find All" part, so you would have to tweak code to do it. Once the document is set up though, it is just a Find and a copy, so you may find it less complicated just to remember it (or make a note about how to do it).

A macro could certainly be written to do this for you, but I would question whether it would be worth the effort. If your requirement is more complex, you may need to consider writing code, but doing so for a single document seems like overkill.

To assign the style, just select the paragraph(s) and use the style pull-down to assign it. You can bring up the Styles and Formatting task bar with all the style names listed as well. To make it even easier, use a keyboard shortcut: once you have set the style once, press the F4 key to repeat the last action for all the rest.
0
 
LVL 1

Author Comment

by:JElster
ID: 22954409
How do you set the styles on a range and view them.
I set one but it never finds it in my test. thx
0
 
LVL 21

Expert Comment

by:Eric Fletcher
ID: 22955785
Not sure I follow... Are you having trouble setting the style to paragraphs or in performing the Find?

In the eeLetters document, the addresses have been set with the "address" style, and if you use the Find dialog as I described, does it find all the instances as shown in the image below?

Note that I have set the style area width (in Tools Options, View dialog) to 0.65" to be able to see the style names applied to the paragraphs. As you can see, only the 12 paragraphs tagged with the address style have been found.
eeQ23889559Word.jpg
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question