Word

Create and Print an Envelope

Ease of Use

Easy

Version tested with

2002 

Submitted by:

Jacob Hilderbrand

Description:

Create an envelope based on the text at the insertion point of the document. 

Discussion:

This macro grabs the text from the insertion point (where the mouse cursor is) to the first paragraph return that contains no text. Your return address is specified in the code. The macro automatically prints the envelope. You'll likely want to assign this macro to a toolbar button or shortcut key. 

Code:

instructions for use

			

Option Explicit Sub Exvelope() Dim ReturnAddress As String ReturnAddress = "Your Name" & vbNewLine & _ "Your Street Address" & vbNewLine & _ "Your City, State, and Zip" Selection.Extend Selection.Find.ClearFormatting With Selection.Find .Text = "^p^p" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue End With Selection.Find.Execute Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend ActiveDocument.Envelope.Printout ReturnAddress:=ReturnAddress End Sub

How to use:

  1. Copy the code above.
  2. Open Word.
  3. Press Alt+F11 to open the Visual Basic Editor (VBE).
  4. Insert-Module.
  5. Paste the code in the Main Code Window for that module.
  6. Close the VBE (Alt + Q or press the X in the top-right corner).
 

Test the code:

  1. Tools-Macro-Macros and double-click Envelope.
 

Sample File:

Envelope.zip 9.24KB 

Approved by mdmackillop


This entry has been viewed 103 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express