The VBA below can get the printout in one pdf:
i.e. upon inputing the page numbers, say 1,3-5,
then pages 1, 3-5 will be exported as one pdf.
How to adjust the VBA so that the pdf will not merge,
and output as separate pdfs, i.e.
pdf file 1 with page 1;
pdf file 3 with page 3;
pdf file 4 with page 4;
pdf file 5 with page 5;
Code:
Sub PrintInOnePdf()
Dim selectionRange As Range
Dim newRange As Range
PrintoutPath = "C:\Users\DK-01\Desktop\Scan\"
Set Sh = ActiveSheet
which = InputBox("Print which pages?")
NameOfFile = which 'before splitting "which"
which = Split(which, ",")
For i = LBound(which) To UBound(which)
part = Split(which(i), "-")
f = part(0)
If UBound(part) = 0 Then
t = f
Else: t = part(1)
End If
GoSub SetRange
Next i
selectionRange.Select
Selection.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=PrintoutPath & NameOfFile & ".pdf", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
End
SetRange:
s = Range("print_area").Address()
P_Area = Split(s, ",")
p = Split(P_Area(0), ":")
Set newRange = Range(Cells(55 * (f - 1) + 1, 2), Cells(55 * t, 13))
If selectionRange Is Nothing Then
Set selectionRange = newRange
Else
Set selectionRange = Application.Union(selectionRange, newRange)
End If
Return
1000 End Sub
i.e. upon inputing the page numbers, say 1,3-5,
then pages 1, 3-5 will be exported as one pdf.
How to adjust the VBA so that the pdf will not merge,
and output as separate pdfs, i.e.
pdf file 1 with page 1;
pdf file 3 with page 3;
pdf file 4 with page 4;
pdf file 5 with page 5;