-
I had to remove a few items (shown in red below) to have the code work correctly but I am still having issues because the Content Control is linked to a variable field (name taken from an Excel data sheet through Mail Marge). This causes the code to save all the files (30+) under the name of the first Content Control ID. an thoughts?
And thank you GMayor for the suggestion however I am not able to download that Add-In to this device.
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules