+ Reply to Thread
Results 1 to 3 of 3

VBA Code to print a worksheet from Excel to a pdf and place in a folder

Hybrid View

maryren VBA Code to print a worksheet... 10-24-2013, 02:38 PM
GooberTron Re: VBA Code to print a... 10-24-2013, 03:48 PM
maryren Re: VBA Code to print a... 10-24-2013, 05:06 PM
  1. #1
    Registered User
    Join Date
    06-12-2013
    Location
    Fairbury NE
    MS-Off Ver
    Excel 2007
    Posts
    70

    VBA Code to print a worksheet from Excel to a pdf and place in a folder

    Hi,
    I know this is possible, just don't know how to write it. I need to print a worksheet from an excel file to a pdf and file it in a specific folder. The name of the worksheet (for an example) can be called PRINT PDF and the name of the folder could be EXCELPDFFILES. Hoping someone can help me with this.
    Last edited by maryren; 10-24-2013 at 05:06 PM.

  2. #2
    Registered User
    Join Date
    08-28-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: VBA Code to print a worksheet from Excel to a pdf and place in a folder

    To save the currently active sheet as a PDF you could use something like the following in code. Hopefully it is obvious that you can modify the constants at the top to suit your filepath and filename;

    Sub SaveAsPDF()
    
    Const FILEPATH As String = "C:\Users\MaryRen\Desktop\Test\"
    Const DOCNAME As String = "mypdf.pdf"
    
        ActiveSheet.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        FILENAME:=FILEPATH & DOCNAME, _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=False
        
    End Sub

  3. #3
    Registered User
    Join Date
    06-12-2013
    Location
    Fairbury NE
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: VBA Code to print a worksheet from Excel to a pdf and place in a folder

    Perfect, thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Excel VBA code for selecting a folder then search & open specified files in that folder
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2021, 03:09 AM
  2. Excel VBA code to read from Word documents in a folder and Print it to Excel
    By Vinod Krishna.C in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-02-2013, 11:04 PM
  3. [SOLVED] Code to print all word documents from a folder
    By Scal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2013, 04:44 PM
  4. Place Excel workbooks into network folder
    By imran91 in forum Excel General
    Replies: 7
    Last Post: 12-13-2012, 08:45 PM
  5. Code to print all files in a folder (to default printer)
    By jwhitwell in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2010, 04:35 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1