| Barry MacDonnell's
Toolbox for WordPerfect
Macros, tips, and
templates for Corel® WordPerfect® for Windows®
| Page updated Apr 3, 2018
|Custom Envelope Launcher - Launch a custom envelope with the mailing address automatically filled in from your letter's address (or just launch a blank custom envelope ready to type or paste an address)|
Related macros -
Purpose and method
WordPerfect can create a filled-in envelope with Format, Envelope, but it loads its own standard (generic) envelope page.
Custom Envelope Launcher.wcm is a macro for WordPerfect 9 (and
later versions) that -
• copies an inside address (i.e.,
the recipient's mailing address, a.k.a. the "address block") from the current document; and
The envelope can have a custom return address area with different fonts, graphics, etc., as well as any other custom designs (watermarks, text boxes, graphic lines, etc.) for the rest of the envelope.
The macro uses a similar method to the
automatic envelope-creating method WordPerfect uses to find an address
on page 1 of your document: It looks for the last block
of 3 to
6 contiguous lines of text on the page, where each line ends in a
single hard return [HRt] (not a line break) and the entire address
block is followed by an empty line (i.e., another hard return). [For
more, see "How WordPerfect finds a mailing address on your letter" here.]
Notes and tips about the address block in a document
¤ Address block lines are only considered "empty" if they do not have characters, WordPerfect symbols (Ctrl+W), spaces, punctuation (including hyphens), or tabs. If they have any of these, they are not considered to be empty lines by the macro, so they will be included in the line count of the (presumed) address block. Hence, be careful about using spaces on lines that should be truly empty.
¤ You can also select an address block and the macro will use it instead. (Be careful not to select too many lines or they might not fit on the envelope.)
¤ Notice that hard returns (via the Enter key) are usually needed to end a short line or a paragraph. On the other hand, line breaks [LnBrk], which can be entered with Ctrl+Shift+L, are often used to also end a line or paragraph (or they are sometimes included if you paste an address from an outside source). You might find them useful to set off areas of text such as a RE: or SUBJ: area below the address block so that their lines will NOT be seen — and counted — as part of the address by the macro. [Alternatively you can enclose these non-address areas in a borderless table (see here for more) or a regular table, since tables are also ignored by the macro.]
¤ Remember, the macro looks for the last qualified block on the first page — i.e., it looks for hard return codes [HRt] that terminate each of the contiguous lines — so if you have more than 2 lines of RE: or SUBJ: matter below the recipient's address you should use line breaks to terminate those paragraphs (or put them inside a borderless or regular table). This will make them invisible to the macro. As noted, you can always force the macro to use a given block of text by selecting it first.Brief background
The first release of WordPerfect 9 (May 1999) created envelopes by appending an envelope page to the current document (unless it was blank, in which case it simply created an envelope page). You didn't get a choice as you did in earlier versions of WPWin to print or append -- you could only append, then print the page.
This macro gives you both print choices and lets you use envelopes with customized features such as a logo, different fonts, or other custom return address area designs.
[Hint: WordPerfect 8 and later versions let you use a QuickWord in the return address field of the envelope dialog to automatically insert these items. See http://wptoolbox.com/tips/CustomRA.html. However, the Custom Envelope Launcher macro lets you use an envelope with your own customized layout — in any area of the envelope, not just the return address area.]Instructions to use the macro
After the custom envelope template has been created and saved (see below), simply open or create a letter. Then, when the recipient's address has been entered in the body of the letter, either (1) play the macro, or (2) select the recipient's address with your mouse or keyboard and then play the macro.
The latter method — selecting the address fiirst — sometimes works better when other items can interfere with the macro's ability to locate the actual address. In fact, if you use a WordPerfect table to contain the address you must select the address in that table cell before playing the macro, otherwise the macro will not see it.
Selecting the address is also slightly faster than the first method, since then there is no need to search the entire page. [See the redlined User Modification Area in the macro for an optional setting that will display a brief Please Wait message, which might help users on older, slower computers. However, this should not be a problem with modern computers.]
Tip: If you play the macro in a new, blank document, it will create an envelope ready for you to type (or paste) the recipient's address. This can be handy to create one envelope or perhaps several solitary custom envelopes, without having to open or create a letter.
Important: The macro will paste the address on the lower part of the custom envelope after all other material — the location you would typically get to with your keyboard using Ctrl+End (or Home,Home,DownArrow with the DOS keyboard). So be sure to set up your custom envelope so that the cursor lands at that end-of-document location when you navigate there with your keyboard. The macro will use the same navigation method.
Modifications and options: You can open the macro (like any WordPerfect document) and edit the settings in the redlined User Modification Area below the comment areas. (Scroll down to about line 278.) You can set the macro to use a specific template (in fact this is required to play the macro), convert the mailing address on the envelope to UPPER case, remove periods and commas from the address, use a postal bar code, etc.Instructions to create the envelope template
See the "Instructions to create the envelope template" section at the top of the macro's code. [These are also repeated for convenience in Footnote 1 below.] You can open a WordPerfect macro for editing / viewing just like any other WordPerfect document.Tips
☼ What is a "mailing address" to the WordPerfect program?
☼ Need to insert a special message on the envelope (e.g., PERSONAL; INVOICE ENCLOSED; etc.) ?
☼ Need more than one envelope for a letter?
☼ If you want to use a different printer for the envelope -
See Footnote 2.
☼ Want to automate some more?
[Continued from above.]
Instructions to create the custom envelope template
- - -
Note that this is quicker and easier done than it is to describe, and for most users it generally is a one-time procedure.
- - -
First, you must create a custom envelope template with your return address area (and any other area) designed the way you would like it to print, and save it to a folder that the macro can locate. Here's one way to do it.
If you already have a custom envelope template, skip down to Step 7. (But first see the Tips in Step 5.)
Step 1. Open a new blank document, then select Format|Page|Page Setup. [You could create a new envelope template with File|New from Project..., but the next steps may be less prone to error for this project and, in any case, they make it clear where the new template resides on your disk.]
Step 2. In the Page Setup dialog's Size tab, choose Envelope #10 or other envelope definition from the list on the left.
If you want to create a new page definition for the envelope (perhaps to change the page size or margins) continue with Step 3. Otherwise, Click OK and skip down to Step 4.
Step 3 (OPTIONAL). In the Page Setup dialog, click on Add. (In earlier versions of WP, click the Options button and then select New.) You can now create a new page definition for your custom envelope.
In the Add New Page Definition dialog -
• In the Name field, give the new page definition a new name (e.g., "CustomEnv"), select Envelope as the Type, and select the Size as "Envelope #10" (or whatever size you are using). Names must be unique.
[When selecting paper that is not the standard size, select “User Defined Size” and enter in the Height and Width below the field. (You can also set a vertical and horizontal printing adjustment later, by editing the definition later.)]
• Click in the Source field, and select the printer tray to use, then click OK to exit from this dialog.
[Note: Here is where you choose the specific tray you want to pull from (the Source). For ordinary ("one tray") print jobs, that's only necessary if you always want the paper to pull from that particular tray, or if your particular printer behaves better if a specific tray is selected in this field.
If your printer offers a "Default" source selection, and if that works for you, it's fine to leave it set that way. Some printers are more finicky than others, but if your printer offers a default source, and if that works well for you and your printer, it's fine to use. (Thanks to CyndyZ for this tip.]
Click the Orientation radio button to select the appropriate orientation (e.g., Landscape, if you insert envelopes into your printer with the narrow edge first). Set the "Show page size" to Current printer only.
• Click OK to exit from these dialogs.
Step 4. You should now see an envelope document on screen (if not, select it from Page Setup), based on the standard (shipping version) WordPerfect envelope template.
• Open the Reveal Codes window with View|Reveal Codes.
• Edit the [Open Style: DocumentStyle] code at the top of the Reveal Codes window by double-clicking it. When the Style Editor dialog opens, choose a default font type and font size for your envelope. This will take precedence on any appended envelope(s) over the letter's font type and size, since the envelope is "downstream" from the letter.
• Click OK when done to close the Styles Editor. You should be back at the envelope document screen.
Step 5. If you have previously entered your name in the address book, you'll see it in the return address area. If not, you can enter it now, along with any graphics, logo, etc.
☼ Return address area:
You can use a table without borders to align the return address area components, or try a text box (Insert|Text Box) that can be dragged into position (right click to specify the position as "Page" and it should not move around—especially if you decide to always center the recipient's address vertically with the setting in the redlined User Modification Area in the macro's code).
If you wish to use a different font from the return address, insert a [Font] code after the return address area but before the mailing address area. (Use Reveal Codes to be sure of the placement.)
☼ Margins and centering the recipient's address:
Horizontal adjustment: Directly below the return address area, you should increase the left margin to the location where the recipient's address will appear.
Vertical adjustment: Add sufficient hard returns with the <Enter> key to position the location of the first line for that address. The macro will seek the "bottom" of the envelope page, so you need to add these empty lines to set the envelope's address first line. (Allow for up to 6 address lines plus another line for the postal bar code, if used.)
Bottom space: Use a minimum bottom margin to accommodate the recipient's address (and bar code, if any) without overflowing to the next page. Note that inkjet printers may have larger page margins than laser printers, so you may need to experiment with the number of hard returns used to center the address vertically (see previous paragraph).
Step 6. Now you can save the envelope document as a template. Assuming you keep such templates in the factory default folder as shown in Tools|Settings|Files|Template, simply choose File|Save As and select this folder to Save In from the drop down list at the top of the Save As window. Be sure to name the template with a .WPT filename extension.
• Print an envelope from the template to test it:
Click File|New from Project..., then in the Create New tab, select the category in the top drop list. In the bottom list you'll see your template (if you don't see it, choose Options|Refresh Projects). Click on the name, then click Create. When the envelope loads, print it with File|Print.
• To edit this template later:
Choose its name in the Project list with a single click, then click Options, then Edit WP Template. (Or you can right-click the template's name and choose Edit WP Template.)
Step 7. IMPORTANT: Edit the location and filename of your new template in the redlined User Modification Area in the macro's code. The macro needs to find the correct template each time it is played.
• In the User Modification Area you can set the macro to print mailing addresses in UPPER CASE, remove commas and periods from the mailing address, add a USPS bar code under the address, etc..
• Click the Save & Compile button on the Macro Toolbar to save all changes to this macro.
Step 8. Place this macro in your WordPerfect default or supplemental macros folder as shown in Tools|Settings|Files|Merge/Macro. Create a toolbar button or menu selection to play it with a mouse click as describe here: http://wptoolbox.com/tips/EasyPlay.html.
Tip: If you need multiple return addresses on envelopes (business, personal, spouse, etc.), or different design customizations for different recipients, make copies of this macro file with slightly different names, and change the name of the envelope templates in each file as described above.
Step 9. Now you can either
(a) play the macro or
(b) select the entire inside address block and then play the macro.
A dialog box will pop up to give you the choice of printing, appending, or aborting.
Note: Playing the macro in a new (empty) document will immediately load the custom envelope so you can type (or paste) an address on it without having an actual letter document open and on screen.
Switching between your normal printer to an envelope printer and back again
[The material below is adapted from a short post on WordPerfect Universe here. That thread also contains a link to a macro from WordPerfect expert Klaus Pfeiffer (see here for his post and download) that you can assign to a menu, toolbar button, or keyboard shortcut (see here) to rapidly change to any installed printer (or fax) driver, print the document or open the envelope dialog, then return WordPerfect to the original printer selection for the current document.]
To print the envelope to a different printer — i.e., your "envelope printer" — and then automatically return WordPerfect's File, Print setting back to the original printer (which information is saved in the document itself):
• Edit the macro (Tools, Macro, Edit).
• Scroll down to about line #635 under the section entitled "Print or Append envelope now" to the Print (CurrentPage!) command (at about line #637).
• Replace that single Print (CurrentPage!) command with these commands:
vPrinter:="" // (i.e. an empty string)
// IMPORTANT: You must edit the next
// command ("PrinterSelectByName(...)")
// to exactly match the name of your
// desired envelope printer.
vPrinter:=PrinterSelectByName (PrinterName: "MyEnvelopePrinter")
Print (CurrentPage!) // (prints whatever page the cursor is on)
// USE JUST ONE of the next two commands. The first will return
// the File, Print setting to a specific printer (here, an Epson); the
// second returns it to the default printer that was selected for the
// current document.
//PrinterSelectByName (PrinterName: "EPSON Stylus C80 Series")
PrinterSelectByName (PrinterName: vPrinter)
• Save your changes with Save & Compile on the Macro Toolbar.
Be sure to test the changes. If the envelope doesn't print, verify that the name of the envelope printer in File, Print is exactly the same as specified in the above macro code. (Even an errant space character can cause the snippet to fail.)