Macro Uses Wrong Paper Drawer (sometimes)

Macro Uses Wrong Paper Drawer (sometimes)

Post by Rick » Wed, 29 Dec 2004 02:10:42


I have written a macro so that when users select the address text in a
letter they can run this macro to select the correct printer and print
the selected text on an envelope.

The macro I pasted below "usually" pulls and prints on an envelope from
the envelope feeder. But for some reason it will occasionally pull
from drawer 4 and print on that paper. I can't figure out what causes
it to fail sometimes or how to ensure that it will always pull an
envelope from the envelope feeder.

thanx for your help with this frustrating issue.
****************************************************
Sub EnvB()
'
' EnvB Macro
'
'
Selection.Copy

Documents.Add DocumentType:=wdNewBlankDocument

With Dialogs(wdDialogFilePrintSetup)
.Printer = "\\PCB_TREE\B1.STL.MO"
.DoNotSetAsSysDefault = True
.Execute
End With

With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = InchesToPoints(2)
.BottomMargin = InchesToPoints(0.2)
.LeftMargin = InchesToPoints(4)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(9.5)
.PageHeight = InchesToPoints(4.13)
.FirstPageTray = wdPrinterEnvelopeFeed
.OtherPagesTray = wdPrinterEnvelopeFeed
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
End With

Selection.PasteAndFormat (wdPasteDefault)

Selection.TypeParagraph
Selection.WholeStory
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft

Application.PrintOut FileName:="", Range:=wdPrintAllDocument,
Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
ManualDuplexPrint:=False, Collate:=True, Background:=True,
PrintToFile:= _
False, PrintZoomColumn:=0, PrintZoomRow:=0,
PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
ActiveDocument.Saved = True
ActiveWindow.Close

End Sub