Solved

Trying to use PrintOut Method to print XPS file to specififed location...

Posted on 2007-04-05
4
1,399 Views
Last Modified: 2012-06-21
Hi,

I have a document called "myDocument.doc" located in the Directory "C:\Documents\Doc\".  I want to write code that will print this in XPS Format (Vista) and save it to its current name, but with the .xps suffix.

Like so:

"C:\Documents\XPS\myDocument.xps"

I believe some form of the following will work, but I don't know how to specify the name I wish to save to:

ActivePrinter = "Microsoft XPS Document Writer"
Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
        ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
        False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0

Any ideas?
0
Comment
Question by:MitchellVII
  • 2
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
gbahri earned 500 total points
ID: 18862465
Here is a work-around for above problem. You'll have to work with 'ActiveDocument'

Rather than using,

Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
        wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
        ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _
        False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0

Use following code:

================================================================================
ActivePrinter = "Microsoft XPS Document Writer"
ActiveDocument.PrintOut Background:=True, outputfilename:="C:\Documents\XPS\myDocument.xps", copies:=1, pagetype:=wdPrintAllPages
================================================================================

This will ensure background printing (with poping up with 'Save As dialog') and file name can be specified here for 'outputfilename'

Hope, this serves your purpose,

thanks,

GBahri


0
 
LVL 5

Author Comment

by:MitchellVII
ID: 18863528
Thanks!

Yes this works.  I would also like to use this printing .pdf files using CutePDF, however, this "printofile" method seems to create corrupted .pdf files that won't open.

Do you know how to adjust this code to work with .pdf's?
0
 
LVL 7

Expert Comment

by:gbahri
ID: 18874256
I've tried using CutePdf, PDF995 and Adobe PDF, but all in vain. In my opinion you should try this in Adobe/PDF section.

Thanks,

GBahri
0
 
LVL 5

Author Comment

by:MitchellVII
ID: 18874854
I am now using Wind2PDF which has some code with it that makes this work very smoothly.  Not bad for a $30 program.  Adobe is just rediculously priced so I avoided.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
The viewer will learn how to make their project stand out over others by learning how to change colors and shapes, add spaces, change directions, and add bullets to their charts.

920 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

13 Experts available now in Live!

Get 1:1 Help Now