MS Excel Macro to print to PDF and save to a certain file name and overright it if necessary

Posted on 2011-10-12
Last Modified: 2012-05-12
I have included a recorded VBA macro that seems to choose PDF as my print option, but then I am asked for a file name.  Is there a way to modify what I have included to save to a file in a particular folder and replace if nesseary.  Many thanks!
Sub Print_to_PDF()
' Print_to_PDF Macro

    Application.ActivePrinter = "Adobe PDF on Ne06:"
    ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,""Adobe PDF on Ne06:"",,TRUE,,FALSE)"
End Sub

Open in new window

Question by:majervis
    LVL 48

    Accepted Solution

    If you use Excel 2007 (like the tags you added shows), you can use ExportAsFixedFormat  method.

    Check this example:

    Author Closing Comment

    Exactly what I was looking for.  Thank you for the fast reply.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
    My experience with Windows 10 over a one year period and suggestions for smooth operation
    This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
    This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

    737 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

    18 Experts available now in Live!

    Get 1:1 Help Now