PDA

View Full Version : Writing to a PDF file from Excel



pico
12-03-2006, 10:42 AM
Hello I would like to save my excel sheet into a pdf file using a macro. First i would like to invoke the excel save-as screen to enter the file name of the pdf file. Once the save button is hit save the file with the name given as a pdf file. How do i go about doing this? I have included my excel sheet.

malik641
12-03-2006, 11:00 AM
Hey Pico,

If you have Adobe Standard (not reader) then I'm pretty sure you can just invoke the PrintOut method via code and change the ActivePrinter to Adobe PDF and it will automatically bring up the saveAs dialogue box. Haven't tested, but I've done that with other programs (CorelDraw, for instance). But make sure you leave PrToFileName blank so you can manually write in the name.

From the help files:

expression.PrintOut(From, To, Copies, Preview, ActivePrinter, PrintToFile, Collate, PrToFileName)

expression Required. An expression that returns an object in the Applies To list.

From Optional Variant. The number of the page at which to start printing. If this argument is omitted, printing starts at the beginning.

To Optional Variant. The number of the last page to print. If this argument is omitted, printing ends with the last page.

Copies Optional Variant. The number of copies to print. If this argument is omitted, one copy is printed.

Preview Optional Variant. True to have Microsoft Excel invoke print preview before printing the object. False (or omitted) to print the object immediately.

ActivePrinter Optional Variant. Sets the name of the active printer.

PrintToFile Optional Variant. True to print to a file. If PrToFileName is not specified, Microsoft Excel prompts the user to enter the name of the output file.

Collate Optional Variant. True to collate multiple copies.

PrToFileName Optional Variant. If PrintToFile is set to True, this argument specifies the name of the file you want to print to.
Hope this helps :thumb

mdmackillop
12-03-2006, 11:04 AM
Hi Pico,
The usual way is simply to print to the PDF programme, which appears on your list of printers. This will normally prompt you for a save name.

JeffT
12-03-2006, 01:41 PM
Pico

If you don't have Adobe standard try this freeware

http://www.pdfforge.org/products/pdfcreator/

I have an early version which works fine on most "Ordinary" file types, but has limited font recognition. Haven't tried this version though.

Jeff