Dear all,
I'm trying to get a macro to have a Word doc (containing multiple pages) split for each page according to specific criteria and each of the created pages saved as a PDF.
So far, I've managed to find below macro, which solves my issue, except of the fact that the PDF files are being saved as Page 1, Page 2, etc.
Sub SaveAsSeparatePDFs()
Dim I As Long
Dim xDlg As FileDialog
Dim xFolder As Variant
Dim xStart, xEnd As Integer
On Error GoTo lbl
Set xDlg = Application.FileDialog(msoFileDialogFolderPicker)
If xDlg.Show <> -1 Then Exit Sub
xFolder = xDlg.SelectedItems(1)
xStart = CInt(InputBox("Start Page", "Page range"))
xEnd = CInt(InputBox("End Page:", "Page range"))
If xStart <= xEnd Then
For I = xStart To xEnd
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
xFolder & "\Page_" & I & ".pdf", ExportFormat:=wdExportFormatPDF, _
OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:= _
wdExportFromTo, From:=I, To:=I, Item:=wdExportDocumentContent, _
IncludeDocProps:=False, KeepIRM:=False, CreateBookmarks:= _
wdExportCreateHeadingBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=False, UseISO19005_1:=False
Next
End If
Exit Sub
lbl:
MsgBox "Enter right page number", vbInformation, "Page range"
End Sub
I'd like to have a specific value used as the name of the PDF doc, which appears on every page in the 3rd line, 39 characters from the left.
In addition, is there a possibility to define a folder in the macro where the PDF's can be saved by default?
Thanks a lot for your help!
Mirza