PDA

View Full Version : [SOLVED:] SAVING RANGE AS PDF FOR MULTIPLE FILES



branston
11-25-2019, 04:17 AM
Hi

My code at the moment cycles through and prints the range on my sheet for all the candidates.

Instead of printing the range I am trying to save all candidate files as pdfs instead. The number of candidates can change (but the range is set in the NameManager if that helps). At the moment I am achieving that by changing the printer to a 'pdf printer' which then gives me a dialogue box to save the file instead. It's frustrating as I have to cycle through all dialogue boxes and save each file.

Is is possible to save the all candidate ranges as pdf files in one go instead of having to 'pdf print' to save each one at a time?

Any help is appreciated.


Public Sub Print_all_candidates()

'-----------------------------------
'CYCLE THROUGH ALL CANDIDATES
With Worksheets("Main")
For i = 1 To 20
.Range("F1") = i
.Range("A1:W40").PrintOut
Next i
End With
Application.ScreenUpdating = True


End Sub

branston
11-25-2019, 06:21 AM
In case any one else needs the code .. thanks to spali



Public Sub Print_all_candidates()

'-----------------------------------
'CYCLE THROUGH ALL CANDIDATES
With Worksheets("Main")
For i = 1 To 20
.Range("F1") = i
'.Range("A1:W40").PrintOut

'''''''''''''''''''''''''''''''''''''''''''''''
FILESAVENAME = ThisWorkbook.Path & "\" & "PDF For Student" & i
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
FILESAVENAME _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False

'''''''''''''''''''''
Next i
End With
Application.ScreenUpdating = True

End Sub