Perhaps a macro like this?
This macro lets the user select a folder, it then loops through all files in this folder and if the file type is xlsx it will open this file and activate Sheet1 and save the used range as a pdf file to a folder i.e. “C:\Temp”
Changes that should be made depending where the data you are located i.e. Sheet1 or a sheet with a specific name. If workbook contains only 1 sheet this will be the active sheet when workbook is opened.
You may probably need to change the range setting and as I have no access to a printer you should record a macro when selecting a range and print that as a pdf document.
Post this macro and then it could be added to this macro.
Option Explicit
Sub ExtrData()
Dim MyFolder As String 'Store the folder selected by the user
Dim sFile As String 'The name of the file where data is selected for printing
Dim wk As Workbook
Dim pFile As String
On Error Resume Next
Application.ScreenUpdating = False
'Display the folder picker dialog box for user selection of directory
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Please select a folder"
.Show
.AllowMultiSelect = False
If .SelectedItems.Count = 0 Then
MsgBox "You did not select a folder"
Exit Sub
End If
MyFolder = .SelectedItems(1) & "\"
End With
'Dir finds the files in the selected folder, to specify a specific filetype replace xlsx with proper file ending
sFile = Dir(MyFolder & "*.xlsx")
If sFile = "" Then
MsgBox "No files matching set criteria found"
Exit Sub
End If
Do While sFile <> ""
Set wk = Workbooks.Open(MyFolder & sFile)
Sheets("Sheet1").Activate
pFile = Mid(sFile, 1, Len(sFile) - 4)
ActiveSheet.UsedRange.ExportAsFixedFormat Type:=xlTypePDF, Filename:="C:\Temp\" & pFile & ".Pdf", Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
wk.Close SaveChanges:=False
sFile = Dir()
Loop
Application.ScreenUpdating = True
End Sub
Alf
Bookmarks