printing envelopes

L

LG6349

I have 10 letters I created and saved in a folder. What is the best way to
print envelopes for each of those letters? I have been highlighting each
address and printing one by one. I know I can do mail merge, but when it's
only a few letters, is there a trick I don't know about to print all of the
letters envelopes with using mail merge.
Also, I want to set my default to a certain font for printing all my
envelope addresses. I have tried styles and formatting but it doesn't work.
 
G

Graham Mayor

There are two issues here - the design of the envelope and the batch
processing.

For the former, see http://www.gmayor.com/changing_envelope_layout.htm

The latter sounds an interesting exercise to keep me amused this weekend.
Does the envelope tool correctly identify the addressee information in your
letters, without having to select it manually? If not how and where
*exactly* does the addressee information appear in your letter. In order to
gather than information from your letter, the macro must be able to locate
and select it in order to transfer it to an envelope. The simplest plan is
to e-mail me a sample letter via the link on the home page of my web site.
By all means change any sensitive information it may contain (It is only the
layout I am interested in) and we will see where we can go from there.

I take it that this is a task that you will be required to repeat on a
regular basis? It is hardly worth creating the macro for a one off.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

I was going out today, but it is raining, so I have come up with the
following. It requires an envelope template that you can download from my
web site. It also requires that you define the address location on the
envelope. My letter templates use the built-in Inside Address paragraph
style to format the addressee information so the address is easy to locate.
Yours I don't know about.

The macro is annotated to show how it works.

Do not even think of running the macro on a folder that contains anything
other than your letters!

Sub BatchPrintEnvelopes()
'Macro requires Envelope #10.dot
'Download from www.gmayor.com
'and extract to the user templates folder
Dim oEnvelope As Document
Dim oAddress As Range
Dim oRng As Range
Dim oVars As Variables
Dim EnvAddress As String
Dim i As Long
Dim strFile As String
Dim strPath As String
Dim strDoc As Document
Dim fDialog As FileDialog

Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
'The envelope template contains automacros, not required
'by this macro, so start by disabling them
WordBasic.DisableAutoMacros 1

With fDialog 'Select the folder containing the letters
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , "List Folder Contents"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With

If Documents.Count > 0 Then 'Close any open documents
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
'Open an envelope document. The one shown is based on
'Envelope #10.dot
Set oEnvelope = Documents.Add(Template:= _
Options.DefaultFilePath(wdUserTemplatesPath) & _
"\Envelope #10.dot", _
NewTemplate:=False, _
DocumentType:=0)
Set oVars = ActiveDocument.Variables

strFile = Dir$(strPath & "*.do?")
'The Envelope #10.dot template includes a bookmark called Address
'in the addressee section. Locate this bookmark and insert
'a Docvariable field caleld vAddress and add a charformat switch
With Selection
.GoTo What:=wdGoToBookmark, Name:="Address"
.Fields.Add Selection.Range, wdFieldDocVariable, _
"""vAddress"" \*Charformat", False
End With
'Open each document from the selected folder
'Use a folder that ONLY contains documents for which
'Envelopes are required
While strFile <> ""
Set strDoc = Documents.Open(strPath & strFile)

'Define the location of the address on the envelope.
'In this example, the address starts at the second paragraph
Set oAddress = strDoc.Paragraphs(2).Range
'Check the next few paragraphs to see if they are formatted
'the 'Inside Address' paragraph style and if so add them to
'the address range
For i = 2 To 9
If strDoc.Paragraphs(i).Style = "Inside Address" Then
oAddress.End = strDoc.Paragraphs(i).Range.End
End If
Next i

oAddress.End = oAddress.End - 1
'If InStr(1, oAddress, Chr(13)) Then
' oAddress = Replace(oAddress, Chr(13), Chr(11))
'End If
'Add the address range to the docvariable which will
'Be used to display the address on the envelope
With oEnvelope
oVars("vAddress").Value = oAddress
.Fields.Update 'Update the docvariable field
.PrintOut 'Print the envelope
End With
'Close the letter document and repeat until all the documents
'have been processed
strDoc.Close wdDoNotSaveChanges
strFile = Dir$()
Wend
CleanUp:
'Restore the automacro function
WordBasic.DisableAutoMacros 0
'Close the envelope
oEnvelope.Close wdDoNotSaveChanges
End Sub

http://www.gmayor.com/installing_macro.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top