Solved

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

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
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 …

832 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