+ Reply to Thread
Results 1 to 1 of 1

Save range of worksheets as individual PDFs

  1. #1
    Registered User
    Join Date
    05-25-2017
    Location
    Lisbon
    MS-Off Ver
    Office 2016
    Posts
    1

    Save range of worksheets as individual PDFs

    Hello,

    I have an excel workbook with about 20 worksheets and need to save a range of sheets as individual PDFs files, each pdf's name the same as the respective worksheet name.

    Appreciate some help with a VBA macro to do this.

    I tried the following code but keep getting a Run time Error "5"; invalid procedure call or argument.

    Option Explicit

    Public Sub SaveWorkbookSheetsAsPDFs()

    Dim WB As Workbook
    Dim WS As Worksheet

    Set WB = Workbooks.Open(Application.GetOpenFilename("Excel workbooks (*.xlsx), *.xlsx"))

    For Each WS In WB.Worksheets
    SaveSheetAsPDF WS
    Next WS

    WB.Close savechanges:=False

    End Sub

    Sub SaveSheetAsPDF(WS As Worksheet)

    WS.ExportAsFixedFormat _
    Type:=xlTypePDF, _
    Filename:=WS.Parent.Path & Application.PathSeparator & WS.Name, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=False

    End Sub

    many thanks,
    Sands
    Last edited by sgaucho; 05-25-2017 at 06:11 PM.

+ 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. Looping through name range and create one pdf instead of individual pdfs
    By igoodable in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-10-2016, 08:13 AM
  2. Replies: 1
    Last Post: 01-30-2016, 08:35 AM
  3. Loop to Save Tab as Individual PDFs
    By CDNcameron in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-30-2015, 06:59 PM
  4. [SOLVED] Save Multiple Worksheets as Individual PDFs
    By jmk8602 in forum Excel General
    Replies: 3
    Last Post: 02-26-2014, 01:26 PM
  5. Macro to save excel worksheets as pdfs and change hyperlinks to work in pdf format
    By crnadeau4 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-06-2013, 12:18 PM
  6. [SOLVED] marco to save all worksheets as PDFs, based on cell info in sheet.
    By abagnall in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-16-2013, 09:31 AM
  7. save many worksheets as individual csv files?
    By applegatecz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-06-2010, 03:58 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