+ Reply to Thread
Results 1 to 3 of 3

Print to PDF and change name sheet

  1. #1
    Registered User
    Join Date
    06-28-2016
    Location
    X
    MS-Off Ver
    X
    Posts
    7

    Print to PDF and change name sheet

    Hi guys,

    I want to print several sheets of my Excel file to a PDF but I don't want the name of the PDF saved to be the same as the worksheet's name. Below you can see the VBA code I am using right now. As you can see the name isn't changed which I tried with other syntax of VBA but can't get it to work.

    If you can help me out that would be great,

    Tnx

    --------

    Private Sub CommandButton3_Click()

    Dim FolderPath As String
    Dim I As Integer
    FolderPath = "X"

    For I = 16 To 24

    Worksheets(I).ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderPath & "\" & _
    Worksheets(I).Name, OpenAfterPublish:=False

    Next

    MsgBox "All PDF's have been successfully exported."

    End Sub

    --------

  2. #2
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    3,952

    Re: Print to PDF and change name sheet

    It's the "Worksheets(I).Name" part that's making the saved PDFs have the same name as the worksheet. I think you could change that value as shown below to get something else:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Print to PDF and change name sheet

    There is no colon in your drive. Use X: rather than X for folderpath.
    Last edited by Kenneth Hobson; 07-07-2016 at 10:53 AM.

+ 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. add sheet and change print area based on number of line items in template
    By AWITCHER in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-18-2016, 08:55 AM
  2. [SOLVED] Spin Button Change, Print Another Sheet
    By putritersenyum in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2015, 08:30 PM
  3. [SOLVED] Automatic date change in excel sheet print out? Needs fixing
    By bob07904 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2014, 01:22 PM
  4. Macro to change a cell and then print the sheet
    By razkowski in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-28-2014, 10:32 AM
  5. change code from print to paste sheet
    By tinkerbelle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2011, 05:50 AM
  6. Print Macro (Code to change the sheet to Landscape)
    By pinkgold in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2009, 08:17 AM
  7. Replies: 0
    Last Post: 08-21-2006, 12:05 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