PDA

View Full Version : [SOLVED:] Macro to Save Only a Certain Range of Pages of DOCX to PDF



TA1993
01-25-2019, 03:50 PM
Hello!

I currently have a Macro that allows me to go to the "Save As PDF" automatically. However, I want to be able to code in the macro to only save pages 2-8 and convert to PDF. I don't want the Macro to actually save it, I want to get to the "Save As" page but have all the options that I want already preselected (save as PDF and convert only pages 2-8). Any help is appreciated:

This is what I currently have:

Sub CreateProposal()
'
' CreateProposal Macro
'
'
With Dialogs(wdDialogFileSaveAs)
.Format = wdFormatPDF
.Show
End With


End Sub

macropod
01-25-2019, 07:08 PM
The SaveAs dialogue doesn't take arguments for a PDF save range. Instead, you need a brute-force approach:

Sub CreateProposal()
SendKeys "%fa{TAB}p%og{TAB}2{TAB}8{ENTER}"
End Sub