+ Reply to Thread
Results 1 to 5 of 5

Save Every Worksheet in a Workbook to individual PDF files that use the worksheet name

  1. #1
    Registered User
    Join Date
    01-05-2012
    Location
    Salinas
    MS-Off Ver
    Excel 2007
    Posts
    22

    Save Every Worksheet in a Workbook to individual PDF files that use the worksheet name

    I am not sure exactly how to do this one task. I want to save to PDF all worksheets within an excel workbook. Each of the worksheets would be saved with worksheet.name & ".PDF". The number of worksheets in any workbook could vary.

    I think that this would involve the following:

    Dim APath As String

    APath = ActiveWorkBook.Path

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    APath & ActiveSheet.Name & ".pdf", _
    Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas _
    :=False, OpenAfterPublish:=False

    I know you can count the number of worksheets in a workbook, but how do you cycle through them (saving each one, then moving to the next) in a loop? You all have been a great help on learning excel macros. Thank you -

  2. #2
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Save Every Worksheet in a Workbook to individual PDF files that use the worksheet name

    I have posted a couple of similar CSV output posts in the past week.
    To cycle through sheets:
    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-05-2012
    Location
    Salinas
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Save Every Worksheet in a Workbook to individual PDF files that use the worksheet name

    Great! Thank you!!

  4. #4
    Registered User
    Join Date
    01-05-2012
    Location
    Salinas
    MS-Off Ver
    Excel 2007
    Posts
    22

    Re: Save Every Worksheet in a Workbook to individual PDF files that use the worksheet name

    Just saw this:

    for s = 1 to sheets.count
    sheets(1).activate
    your code
    next

    should be:

    for s = 1 to sheets.count
    sheets(s).activate
    your code
    next

    Works perfectly. Thanks again

  5. #5
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Save Every Worksheet in a Workbook to individual PDF files that use the worksheet name

    Scmidt62
    Happy to help, sorry about the typo.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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