+ Reply to Thread
Results 1 to 17 of 17

Mass Worksheet PDF Code

  1. #1
    Forum Contributor
    Join Date
    11-19-2019
    Location
    Michigan
    MS-Off Ver
    Office 365
    Posts
    546

    Mass Worksheet PDF Code

    I have a large file around 200 sheets. Currently I use KuTools to pdf the sheets but it now crashes and I have to do a little bit at a time and cannot select the entire list.

    Is it possible to write a code that would PDF all worksheets with the following naming standard 101254_Smith. The worksheets are separated by an underscore, the first set is the employee ID and the part after is the last name.


    I am not sure why its crashing, perhaps its the add in but if possible I would like to try a different approach.

    Take care all.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Mass Worksheet PDF Code

    Do you want to save each sheet as an individual PDF file? When you say:
    all worksheets with the following naming standard 101254_Smith
    do you mean that each sheet is named based on employee ID and last name? Do you want to save the PDF files in the same folder as your large file?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Mass Worksheet PDF Code

    Here is assuming the first 6 characters in the sheet name are numeric. We can loop through the sheet names, add the sheet to an array to pdf the file.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    11-19-2019
    Location
    Michigan
    MS-Off Ver
    Office 365
    Posts
    546

    Re: Mass Worksheet PDF Code

    Sorry I was terrible at my description. The files have to be individual sheets with the file name being the same as the sheet name. So for example, 101254_Smith.pdf. This is very important to me since there is another job we run that takes the employee id from the file name, matches it up to their email and emails it out to them. I always save the file in a different folder since this is a monthly job and I keep the months separate in a separate folder . I hope this is a better explanation that I provided.

  5. #5
    Forum Contributor
    Join Date
    11-19-2019
    Location
    Michigan
    MS-Off Ver
    Office 365
    Posts
    546

    Re: Mass Worksheet PDF Code

    So not all the employee id are 6 characters, some are 3 depending what year they got hired in. The file names have to individual sheets and have to be named the same as the sheet name. So 101254_Smith.pdf as an example. Sorry if this is a big burden to change. I save these files in different folders each month, can I have the program ask me which folder to put in...or have me select it? NOt sure if this is possible, unfortunately my VBA Skills are super novice.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Mass Worksheet PDF Code

    Try:
    Please Login or Register  to view this content.
    Last edited by Mumps1; 09-26-2020 at 11:40 AM.

  7. #7
    Forum Contributor
    Join Date
    11-19-2019
    Location
    Michigan
    MS-Off Ver
    Office 365
    Posts
    546
    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    I have not tried it but is the code set up to PDF only files with th naming standard I described. Just curious. Thank you for your solution.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Mass Worksheet PDF Code

    Yes it is.

  9. #9
    Forum Contributor
    Join Date
    11-19-2019
    Location
    Michigan
    MS-Off Ver
    Office 365
    Posts
    546

    Re: Mass Worksheet PDF Code

    So I just got a chance to test the code. I am getting an error using it in my master file, the error is Run-time 5: Invalid procedure or call argument. and it is referencing this section when I click on Debug:

    Please Login or Register  to view this content.
    When I exported just a few of my worksheets from my mast file to a a test file, one with a 102125_Smith name and Dashboard List without the underscore. It PDFed both tabs fine, but I was hoping it would ignore the Dashboard List tab as it doesn't have an underscore and only PDF the file with the underscore.

    It must not like one of the worksheets in my file. I do not have enough debugging experience to correct this unfortunately.
    Thank you for your consideration.

  10. #10
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Mass Worksheet PDF Code

    It could be possible the worksheet name is not a legal name and also the file extension could be required.

    ws.Name & ".pdf"

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Mass Worksheet PDF Code

    This version will ignore the "Dashboard List" sheet.
    Please Login or Register  to view this content.
    When you get the error, hover the mouse over this part of the code: ws.Name
    The name of the problem sheet should be displayed.

  12. #12
    Forum Contributor
    Join Date
    11-19-2019
    Location
    Michigan
    MS-Off Ver
    Office 365
    Posts
    546

    Re: Mass Worksheet PDF Code

    I tried the ws.Name & ".pdf" but that created a compile error. I just kept on trying different combinations and this is what I discovered. The code stopped at hidden sheets and threw this exception when I un-hided these sheets the code worked. and it PDFed everything quite efficiently I would say.

    I would like to alter this code so that it ONLY pdfs sheets with a naming standard of 101021_Smith. The first set of numbers is an employee ID separated always by an underscore and then the last name. Is it possible to change the code that it looks for numbers before the underscore, it must have an underscore and just grabs those files for PDF?
    This would help me tremendously. Thank you all. At least I have taken a stab at debugging lol.


    Thank you again.

  13. #13
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Mass Worksheet PDF Code

    This version will work with only those sheets that contain an underscore.
    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    11-19-2019
    Location
    Michigan
    MS-Off Ver
    Office 365
    Posts
    546

    Re: Mass Worksheet PDF Code

    First of all Mumps1 thank you for your patience with me. I am trying as best as I can to try to figure it out but its like shooting darts in the dark. It still seems to stop at hidden sheets and throws out this exceptions. Is it possible to insert a piece of code in there to ignore hidden sheets. Thank you thank you again. I am at your mercy.

  15. #15
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Mass Worksheet PDF Code

    Try:
    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    11-19-2019
    Location
    Michigan
    MS-Off Ver
    Office 365
    Posts
    546

    Re: Mass Worksheet PDF Code

    That did it! Thank you. Beautiful!

  17. #17
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: Mass Worksheet PDF Code

    You are very welcome.

+ 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. Help | Fix this VBA CODE [Used for Excel as mass bulk checker for VIES EUROPE]
    By fuegox in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-08-2020, 05:42 PM
  2. VBA Code - Mass Emails
    By kamccar in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2019, 04:07 PM
  3. Mass find of cells with numbers that are within 'column b' of a worksheet
    By Christypl in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-09-2018, 08:22 PM
  4. [SOLVED] Help with VBA mass find and replace code for exact numbers
    By mguti in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-03-2016, 02:02 AM
  5. [SOLVED] VBA code for mass email not working HELP!!!!!
    By jcushing82 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 05-28-2015, 04:01 PM
  6. Worksheet Code Launches Diifferent Worksheet Code - PivotTableUpdate
    By sample57 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2013, 04:33 PM
  7. Mass Search and Replace within 1 Worksheet
    By Jeff_Johnson in forum Excel General
    Replies: 3
    Last Post: 05-28-2009, 05:21 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