Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
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:
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 …

762 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

17 Experts available now in Live!

Get 1:1 Help Now