View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Michael Bednarek[_8_] Michael Bednarek[_8_] is offline
external usenet poster
 
Posts: 21
Default Print on PDF file

On Mon, 27 Dec 2004 10:02:07 -0800, Gord Dibben <gorddibbATshawDOTca
wrote in microsoft.public.excel.programming:

Michael mentions Ghostscript.

I have had success with the free file downloads and instructions for use here
at Dale Nurden's site.

The use of Ghostscript is the key point with this method.

http://www.rcis.co.za/dale/info/pdfguide.htm

Saves first to single *.ps file which is then converted to *.pdf

Returns one PDF file from multiple sheets.


That still does not cover the OP's (and mine) request for a method which
will work from VBA (without resorting to uglies like SendKeys).

So far, the only methods I have found involve modifying the PDF-creating
program's (Ghostscript, RedMod, PDFCreator) registry entries where they
store the filename and path. Printing to a fixed filename/path and
subsequent move/rename is probably also a possibility, but I haven't
explored that yet. I suspect it might be problematic with multiple print
jobs.

I would appreciate any pointers to a COM add-in interface to produce
PDF files.

On Mon, 27 Dec 2004 22:16:57 +1000, Michael Bednarek
wrote:

On Mon, 27 Dec 2004 09:14:19 +0100, "Thanos"
wrote in
microsoft.public.excel.programming:

is there anyone who knows how to create a PDF file of the active worksheet
through VBA code ?
I tried many examples found on the net with no success...


If you have full Acrobat (not just the Reader), you can use several
methods:

1) Set the active printer to Distiller and simply use the method
.Printout - from memory, that will present a problem regarding the
filename selection

2) Adobe Distiller provides its own print method: FileToPDF.

If you don't have full Acrobat, you could use Ghostscript and RedMon.
Then you have to manipulate the RedMon registry entry which holds the
output filename. This will involve some nasty registry read/write
actions and dealings with the obscure way Excel uses printer names and
ports (different to any other MS Office application).

I have implemented the latter here, where a macro prints a number of
spreadsheets (10) rapidly to PDF files (saving paper). However, about
once a week that process plays havoc with one particular PC's display:
no refresh in any window -including TaskMgr-, completely nuts.

Like you, I'm looking for a stable add-on which will provide the
equivalent to Adobe's FileToPDF; the full Acrobat is just to expensive
for that. The radical alternative, OpenOffice or Quattro, which both
provide native PDF output, is unfortunately not practical for us. It
might be for you, though.

Let us know if you find anything.


--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"