Solved

Word 2010 - print to specific printer

Posted on 2013-01-10
4
300 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
  • 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I'm writing to share my clumsy experience in using this elegant tool so you can avoid every stupid mistake I made. (I leave it to the authorities to decide if this deserves a place in the Knowledge archives.)  Now that I am on the other side of my l…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now