I have Excel 2010 and Adobe Reader 10.0. I have a workbook with 70 tabs that I need to print to individual pdf files named the same as the tab name. How can I do that?
I have Excel 2010 and Adobe Reader 10.0. I have a workbook with 70 tabs that I need to print to individual pdf files named the same as the tab name. How can I do that?
Paste this code into a module and run it.
Hope this helps.![]()
Sub TabsPDF() 'Declare variables Dim mydir As String Dim sh As Worksheet Dim oldactivesheet As Worksheet Application.ScreenUpdating = False 'Store a reference to the active sheet Set oldactivesheet = ActiveSheet 'Prompt the user for a directory to store the PDF files With Application.FileDialog(msoFileDialogFolderPicker) .InitialFileName = Application.DefaultFilePath & "\" .Title = "Please select a location to store your PDF files." .Show If .SelectedItems.Count = 0 Then MsgBox "Cancelled" Exit Sub Else mydir = .SelectedItems(1) & "\" End If End With 'Loop through each tab For Each sh In Worksheets sh.Activate 'Create PDF file and save to mydir ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ mydir & sh.Name, Quality:=xlQualityStandard, _ IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _ False Next sh Application.ScreenUpdating = True 'Reactivate the original active sheet oldactivesheet.Activate MsgBox "All PDF files have been created and stored in " & mydir & "." End Sub
_____________________________
[1] If this reply was helpful, click the star to the left.
[2] If this reply answered your question, mark this thread as [SOLVED].
Last edited by Dimitrov; 09-18-2013 at 10:59 PM.
This is fantastic - worked first time - just saves them all into the directory.
however in addition I want it to then attach each pdf into an email with some standard text in the body of the email and standard subject (but sent to different people) how would i do this please would i need a separate module of code or could it be added to this one.
I then am trying to create a button to run this on click....?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks