Consulting

Results 1 to 3 of 3

Thread: Excel to PDF

  1. #1
    VBAX Regular
    Joined
    Feb 2009
    Posts
    54
    Location

    Excel to PDF

    Am Trying to write a code to print all excel files in a folder to PDF.

    A simple record shows

    [VBA]Sub Macro1()


    Sheets(Array("1", "2", "3", "4", "5", "6", "7", "8", "9")).Select
    Sheets("1").Activate
    Application.ActivePrinter = "Adobe PDF on Ne00:"
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    ActiveCell.Offset(7, 10).Range("A1").Select
    End Sub[/VBA]


    I could write a code so as to run the same for every excel file in a folder. However,

    1. Each time, excel would prompt "Save as". Can it be set as default as the excel file name?
    2. Also have to turn off "View PDF Results" for each file


    Have tried to look up on the net. Can't seem to find anything.
    Thanks in advance

    cheers,

    PSL

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    These would need to be set in Adobe. I've tried such printing in other PDF print programmes with mixed success and unexpected results. I've no access to Adobe PDF.
    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'

  3. #3
    VBAX Contributor
    Joined
    Jun 2007
    Posts
    150
    Location
    You can do all of that with Registry Keys, but its largely undocumented.

    You can even print to PDF silently, but that requires editing binary Registry Keys, and so is a little tricky from VBA.

    Ask yourself how badly you need this feature; how deep down the rabbit hole are you willing to go? I spent weeks developing my PDF printing code.

Posting Permissions

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