Solved

Word 2010 - print to specific printer

Posted on 2013-01-10
4
304 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

749 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