'run this sub first to get the ID of the Content Control
'take note of the number and substitute it to "xXx" (do not remove the Quoute (")) in SaveAsSeparatePDFs() sub
'note: You only need to get the ID number once.
Private Sub x()
Dim ctl As ContentControl
For Each ctl In ThisDocument.ContentControls
Debug.Print ctl.ID, ctl.Range.Text
Next
End Sub
Sub SaveAsSeparatePDFs()
'UpdatebyExtendoffice20181120
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", "KuTools for Word"))
xEnd = CInt(InputBox("End Page:", "KuTools for Word"))
If xStart <= xEnd Then
For I = xStart To xEnd
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
xFolder & ThisDocument.ContentControls("xXx").Range.Text & "_" & 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, "KuTools for Word"
End Sub