The VBA can do the following:
1. Input print pages (e.g. 3,6,4)
2 .VBA can print out as pdf all input pages, but not in order (i.e. 6,3,4).
How to modify the VBA so that the print out is in order of input pages, i.e. 3,6,4?
1. Input print pages (e.g. 3,6,4)
2 .VBA can print out as pdf all input pages, but not in order (i.e. 6,3,4).
How to modify the VBA so that the print out is in order of input pages, i.e. 3,6,4?
Code:
Sub PrintSOR()
On Error GoTo 1000
ro = ActiveCell.Row
co = ActiveCell.Column
Dim selectionRange As Range
Dim newRange As Range
PrintoutPath = "C:\Users\DK-01\Desktop\Scan\"
Set Sh = ActiveSheet
n = ActiveSheet.HPageBreaks.Count
which = InputBox("Print pages (1,3,5-" & n & ")?", PrintoutPath, "1-" & n)
NameOfFile = 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
Cells(ro, co).Select: End
SetRange:
s = Range("print_area").Address()
P_Area = Split(s, ",")
p = Split(P_Area(0), ":")
PL = Mid(p(0), 2, InStrRev(p(0), "$") - 2) ' left of printarea = B
PR = Mid(p(1), 2, InStrRev(p(0), "$") - 2) ' right of printarea
Set newRange = Range(Cells(55 * (f - 1) + 1, Asc(PL) - 64), Cells(55 * t, Asc(PR) - 64))
If selectionRange Is Nothing Then
Set selectionRange = newRange
Else
Set selectionRange = Application.Union(selectionRange, newRange)
End If
Return
1000 End Sub