Consulting

Results 1 to 4 of 4

Thread: Writing to a PDF file from Excel

  1. #1
    VBAX Contributor
    Joined
    Nov 2006
    Posts
    107
    Location

    Writing to a PDF file from Excel

    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.

  2. #2
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    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




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

  3. #3
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Contributor JeffT's Avatar
    Joined
    Oct 2004
    Location
    Maidenhead, Nr London UK
    Posts
    105
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •