#1
|
|||
|
|||
Printing Macro
Hi, basically, I am trying to add 3 macro buttons to the Ribbon that prints to 3 different trays. The exception is the letterhead which prints the first sheet to tray 2 and the rest to tray 3. The problem is, once any of the macros have been used, it changes the default printer to the last one used for some reason. Below is the code and any help would be much appreciated.
Sub Plain() ' ' Plain Macro ' ' Selection.WholeStory With ActiveDocument.Styles(wdStyleNormal).Font If .NameFarEast = .NameAscii Then .NameAscii = "" End If .NameFarEast = "" End With With ActiveDocument.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = CentimetersToPoints(2.54) .BottomMargin = CentimetersToPoints(2.54) .LeftMargin = CentimetersToPoints(2.54) .RightMargin = CentimetersToPoints(2.54) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(1.25) .FooterDistance = CentimetersToPoints(1.25) .PageWidth = CentimetersToPoints(21) .PageHeight = CentimetersToPoints(29.7) .FirstPageTray = 257 .OtherPagesTray = 257 .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _ wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _ PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End Sub Sub Letter() ' ' Letter Macro ' ' ActivePrinter = "Letterhead" Selection.WholeStory With ActiveDocument.Styles(wdStyleNormal).Font If .NameFarEast = .NameAscii Then .NameAscii = "" End If .NameFarEast = "" End With With ActiveDocument.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = CentimetersToPoints(2.54) .BottomMargin = CentimetersToPoints(2.54) .LeftMargin = CentimetersToPoints(2.54) .RightMargin = CentimetersToPoints(2.54) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(1.25) .FooterDistance = CentimetersToPoints(1.25) .PageWidth = CentimetersToPoints(21) .PageHeight = CentimetersToPoints(29.7) .FirstPageTray = 258 .OtherPagesTray = 259 .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _ wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _ PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End Sub Sub Continuation() ' ' Continuation Macro ' ' ActivePrinter = "Continuation" Selection.WholeStory With ActiveDocument.Styles(wdStyleNormal).Font If .NameFarEast = .NameAscii Then .NameAscii = "" End If .NameFarEast = "" End With With ActiveDocument.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = CentimetersToPoints(2.54) .BottomMargin = CentimetersToPoints(2.54) .LeftMargin = CentimetersToPoints(2.54) .RightMargin = CentimetersToPoints(2.54) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(1.25) .FooterDistance = CentimetersToPoints(1.25) .PageWidth = CentimetersToPoints(21) .PageHeight = CentimetersToPoints(29.7) .FirstPageTray = 259 .OtherPagesTray = 259 .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _ wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _ PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End Sub |
#2
|
||||
|
||||
Cross-posted at: http://www.mrexcel.com/forum/general...ing-macro.html
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184 PS: When posting code, please use the code tags, indicated by the # button on the posting menu.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Any answers? Anybody? Anywhere?
|
#4
|
||||
|
||||
See http://www.gmayor.com/fax_from_word.htm
which contains code examples that should work for you.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
Thanks Graham for your reply. I had a look at your site and I understand the code but I'm not sure where I would make the changes in my code. Could you point out where and what I should change please?
Code: Code:
Sub Plain() ' ' Plain Macro ' ' ActivePrinter = "Plain" Selection.WholeStory With ActiveDocument.Styles(wdStyleNormal).Font If .NameFarEast = .NameAscii Then .NameAscii = "" End If .NameFarEast = "" End With With ActiveDocument.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = CentimetersToPoints(2.54) .BottomMargin = CentimetersToPoints(2.54) .LeftMargin = CentimetersToPoints(2.54) .RightMargin = CentimetersToPoints(2.54) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(1.25) .FooterDistance = CentimetersToPoints(1.25) .PageWidth = CentimetersToPoints(21) .PageHeight = CentimetersToPoints(29.7) .FirstPageTray = 257 .OtherPagesTray = 257 .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _ wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _ PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End Sub Sub Letter() ' ' Letter Macro ' ' ActivePrinter = "Letterhead" Selection.WholeStory With ActiveDocument.Styles(wdStyleNormal).Font If .NameFarEast = .NameAscii Then .NameAscii = "" End If .NameFarEast = "" End With With ActiveDocument.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = CentimetersToPoints(2.54) .BottomMargin = CentimetersToPoints(2.54) .LeftMargin = CentimetersToPoints(2.54) .RightMargin = CentimetersToPoints(2.54) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(1.25) .FooterDistance = CentimetersToPoints(1.25) .PageWidth = CentimetersToPoints(21) .PageHeight = CentimetersToPoints(29.7) .FirstPageTray = 258 .OtherPagesTray = 259 .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _ wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _ PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End Sub Sub Continuation() ' ' Continuation Macro ' ' ActivePrinter = "Continuation" Selection.WholeStory With ActiveDocument.Styles(wdStyleNormal).Font If .NameFarEast = .NameAscii Then .NameAscii = "" End If .NameFarEast = "" End With With ActiveDocument.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = CentimetersToPoints(2.54) .BottomMargin = CentimetersToPoints(2.54) .LeftMargin = CentimetersToPoints(2.54) .RightMargin = CentimetersToPoints(2.54) .Gutter = CentimetersToPoints(0) .HeaderDistance = CentimetersToPoints(1.25) .FooterDistance = CentimetersToPoints(1.25) .PageWidth = CentimetersToPoints(21) .PageHeight = CentimetersToPoints(29.7) .FirstPageTray = 259 .OtherPagesTray = 259 .SectionStart = wdSectionNewPage .OddAndEvenPagesHeaderFooter = False .DifferentFirstPageHeaderFooter = False .VerticalAlignment = wdAlignVerticalTop .SuppressEndnotes = False .MirrorMargins = False .TwoPagesOnOne = False .BookFoldPrinting = False .BookFoldRevPrinting = False .BookFoldPrintingSheets = 1 .GutterPos = wdGutterPosLeft End With Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _ wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=False, _ PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End Sub |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Word documents all are now printing in the top right corner as well as cutting off some printing | MattyJ | Word | 2 | 03-20-2015 10:15 AM |
Possible Macro to read and change name whilst printing certificate | DaZ | Excel Programming | 5 | 09-06-2014 10:50 AM |
Possible Macro to read and change name whilst printing certificate | DaZ | Word VBA | 3 | 09-05-2014 05:31 PM |
Macro\Form controls not displayed when printing? | shabbaranks | Word | 1 | 07-13-2012 04:20 AM |
Non-Printing Graphics vs Printing | v_kiviranna | Drawing and Graphics | 4 | 06-29-2010 07:04 AM |