Solved

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

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
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 walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:

733 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