Solved

Word 2010 - print to specific printer

Posted on 2013-01-10
4
306 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 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

623 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