View Single Post
 
Old 08-13-2021, 09:26 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You cannot use non-contiguous ranges with ExportAsFixedFormat you would need to use the PDF printer driver to achieve that. e.g.


Code:
Sub PrintAsPDF()
'Graham Mayor - https://www.gmayor.com - Last updated - 14 Aug 2021
Dim sPrinter As String
Dim sRange As String
    On Error GoTo lbl_Exit
    sPrinter = Application.ActivePrinter
    ActivePrinter = "Microsoft Print to PDF"
    sRange = InputBox("Enter the range of pages to be printed eg 1" & vbCr & _
                      "or 1-3" & vbCr & _
                      "or 1-3,6", "Print Pages")
    If sRange = "" Then
        MsgBox "No pages selected!", vbCritical, "Print Pages"
        GoTo lbl_Exit
    End If
    Application.PrintOut FileName:="", _
                         Range:=wdPrintRangeOfPages, _
                         Item:=wdPrintDocumentWithMarkup, _
                         copies:=1, _
                         Pages:=sRange, _
                         PageType:=wdPrintAllPages, _
                         collate:=True, _
                         Background:=False, _
                         PrintToFile:=False, _
                         PrintZoomColumn:=0, _
                         PrintZoomRow:=0, _
                         PrintZoomPaperWidth:=0, _
                         PrintZoomPaperHeight:=0
lbl_Exit:
    Application.ActivePrinter = sPrinter
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote