+ Reply to Thread
Results 1 to 9 of 9

Excel 2010 multiple sheet selected to save each as a different PDF file

  1. #1
    Registered User
    Join Date
    01-31-2014
    Location
    Madrid
    MS-Off Ver
    Excel 2010
    Posts
    5

    Excel 2010 multiple sheet selected to save each as a different PDF file

    Hello guys, I'm quite newbie with VBA.

    I have a huge file with around 30 sheets and increasing. I've setup 2 different macros. The first one would apply a PageSetup and split the sheet into 7 different pages and the second one would save it as pdf with defined filename from cell value (I've splitted them cos the first one takes a while to apply).

    The problem is that if I have to save several sheets by selecting them (select and CNTRL each one) and run my macro it will save the same file with all pages from all sheets selected. E.g. if I've selected 3 sheets (21 pages in total) it will create 3 different pdf files with all 21 pages. AND I WANT EACH ONE SEPARATELY!!!

    This is my macro:

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor
    Join Date
    12-14-2013
    Location
    Tilburg, Nederland
    MS-Off Ver
    Excel 2010
    Posts
    256

    Re: Excel 2010 multiple sheet selected to save each as a different PDF file

    You use ActiveSheet.export ??? Thats all active sheets.

    Use:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-31-2014
    Location
    Madrid
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Excel 2010 multiple sheet selected to save each as a different PDF file

    Hello Gerard,

    I've used your code with correct path and still no change, it keeps saving all sheets at the same pdf 3 times with different names according to the cell reference. it looks like it's taking correctly the Fname value, but then it applies the export to all selected sheets. Could it be that save as pdf options from excel, since it's different than export to other file extension, does always apply to all selected ones, even if it's not activated???

  4. #4
    Forum Contributor
    Join Date
    12-14-2013
    Location
    Tilburg, Nederland
    MS-Off Ver
    Excel 2010
    Posts
    256

    Re: Excel 2010 multiple sheet selected to save each as a different PDF file

    That's not what I see in my testing, the code that I have posted, is creating an PDF file for each sheet that was selected.
    I will get multi pages when I put in page breaks.

    What do you see in the print preview?
    Have You tried the code in a new workbook, only setting name to the B2 for several sheets?

    When you want to export part of the sheet, setting the PrintArea to the part you want to export works for me

    Otherwise provide sample workbook what has the problem.

  5. #5
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Excel 2010 multiple sheet selected to save each as a different PDF file

    This should work

    Please Login or Register  to view this content.
    If you are pleased with a member's answer then use the Star icon to rate it.

  6. #6
    Registered User
    Join Date
    01-31-2014
    Location
    Madrid
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Excel 2010 multiple sheet selected to save each as a different PDF file

    Hi Gerard, thanks for trying!

    I've copied in a new workbook, define an specific print area in each of them and run the macro (no pagebreak or anything weird in it). Same is happening...

  7. #7
    Forum Contributor
    Join Date
    12-14-2013
    Location
    Tilburg, Nederland
    MS-Off Ver
    Excel 2010
    Posts
    256

    Re: Excel 2010 multiple sheet selected to save each as a different PDF file

    Supply the test workbook where the problem occurs..

  8. #8
    Registered User
    Join Date
    01-31-2014
    Location
    Madrid
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Excel 2010 multiple sheet selected to save each as a different PDF file

    Great Buran, thanks a lot!! It actually helps. It was what I thought in my first reply. save as PDF will print all selected sheets into one, so they key was to unselect all and individually keep selecting each before printing.

    Thanks a lot!!!

  9. #9
    Registered User
    Join Date
    01-31-2014
    Location
    Madrid
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Excel 2010 multiple sheet selected to save each as a different PDF file

    Buran solution worked just fine Gerard. Thanks for helping anyway!!!!

+ 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] One Report, create multiple sheets, save each sheet in a seperate excel file
    By sammymalta in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-04-2013, 07:12 AM
  2. Excel 2010 can not save file to CD need help
    By FlyUK in forum Excel General
    Replies: 1
    Last Post: 06-07-2013, 06:17 PM
  3. Replies: 8
    Last Post: 04-24-2013, 10:16 AM
  4. Excel 2010 file with VBA save and send code works-but file can't be found.
    By carlton.clay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2013, 09:46 AM
  5. Replies: 1
    Last Post: 01-16-2013, 02:02 AM

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