Solved

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

Posted on 2007-04-05
4
1,444 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
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 Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

766 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