Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Word 2010 - print to specific printer

Posted on 2013-01-10
4
Medium Priority
?
308 Views
Last Modified: 2013-01-10
Dear Experts

I have a macro to print a word doc to PDF which is below.  But the code changes the default printer but I am keen to keep the user's default printer as is. I am assuming that there are 2 ways to tackle this:

Option 1: modify the code below so it doesn't change the default printer

Option 2: record the details the of the default printer, then run this code & then set the default back again.

I'm easy on either method if they're both "good practice"

Sub PDF()
    
' Print to PDF macro

ActivePrinter = "PDFCreator"
    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

Open in new window


Can anybody help?
0
Comment
Question by:correlate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 38763031
How about?
Sub PDF()
Dim strActivePrinter As String
' Print to PDF macro
strActivePrinter = ActivePrinter
ActivePrinter = "PDFCreator"
    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
ActivePrinter = strActivePrinter
End Sub

Open in new window

0
 

Author Closing Comment

by:correlate
ID: 38763047
Perfect - thank you for the swift response
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38763059
If you need to print to a particular printer, you must make it the active printer. The printer is not an argument in the PrintOut method .
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 38763063
Swift acceptance too! Thank you.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is written from a 'VBA for MS Word' perspective, but I am sure it applies to most other MS Office components where VBA is used.  One thing that really bugs me is slow code, ESPECIALLY when it's mine!  In programming there are so many ways to…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question