I need to batch print protected PDF files returned by teachers. I currently have a VBA programs that does this for the original Excel files.
But as I want to send PDF instead, once they return protected, I hope to be able to alter the current VBA to print the PDF files.
- I want to open and print the PDF based upon the file name
- I would like to print only the first page.
I have included the VBA to print the original Excel files, but now wish to print PDF files instead
Sub PrintWorkbooks()
Dim cell, rng As Range
Dim wb_loc, wb_name, wb_ext, wb_pw As String
Dim wkbk As Workbook
wb_loc = "\\xxxx\JP-DFS-200\BVC\BVC\Freelance\Signed\"
wb_ext = ".xl*"
Set rng = Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
For Each cell In rng
wb_name = cell.Value
wb_pw = cell.Offset(0, 1).Value
If Dir(wb_loc & wb_name & wb_ext) <> "" Then
Set wkbk = Workbooks.Open(Filename:=wb_loc & wb_name & wb_ext, Password:=wb_pw)
Sheets("Invoice").PrintOut Copies:=1
wkbk.Close SaveChanges:=False
End If
Next cell
End Sub
The passwords are held on an excel sheet in the workbook with *filename*.* in a list.
A: Sheetfilename*.* B: corresponding PW
Bookmarks