How to save each page as separate pdf files in a Word document?
While using Microsoft Word document, you can save each page as separate pdf files one by one with its build-in Save As function. However, if there are hundreds of pages need to be split and saved as individual pdf files, how can you do? This article provides method for you to quickly solve this problem.
The below VBA code helps you to quickly save each page in a document as individual pdf files at the same time. Please do as follows.
1. Open the document you will save each page or specific pages as pdf files, then press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module, copy below VBA code into the Module window.
VBA code: Save each page as separate pdf files at the same time in a Word document
Sub SaveAsSeparatePDFs() 'Updated by Extendoffice 20180906 Dim I As Long Dim xStr As String Dim xPathStr As Variant Dim xDictoryStr As String Dim xFileDlg As FileDialog Dim xStartPage, xEndPage As Long Dim xStartPageStr, xEndPageStr As String Set xFileDlg = Application.FileDialog(msoFileDialogFolderPicker) If xFileDlg.Show <> -1 Then MsgBox "Please chose a valid directory", vbInformation, "Kutools for Word" Exit Sub End If xPathStr = xFileDlg.SelectedItems(1) xStartPageStr = InputBox("Begin saving PDFs starting with page __? " & vbNewLine & "(ex: 1)", "Kutools for Word") xEndPageStr = InputBox("Save PDFs until page __?" & vbNewLine & "(ex: 7)", "Kutools for Word") If Not (IsNumeric(xStartPageStr) And IsNumeric(xEndPageStr)) Then MsgBox "The enterng start page and end page should be number format", vbInformation, "Kutools for Word" Exit Sub End If xStartPage = CInt(xStartPageStr) xEndPage = CInt(xEndPageStr) If xStartPage > xEndPage Then MsgBox "The start page number can't be larger than end page", vbInformation, "Kutools for Word" Exit Sub End If If xEndPage > ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) Then xEndPage = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages) End If For I = xStartPage To xEndPage ActiveDocument.ExportAsFixedFormat xPathStr & "\Page_" & I & ".pdf", _ wdExportFormatPDF, False, wdExportOptimizeForPrint, wdExportFromTo, I, I, wdExportDocumentWithMarkup, _ False, False, wdExportCreateHeadingBookmarks, True, False, False Next End Sub
3. Press the F5 key to run the code.
4. In the Browse window, select a folder to save the pdf files and click the OK button. See screenshot:
5. In the first Kutools for Word dialog box, enter the start page number of your document into the text box and click OK.
6. In the second Kutools for Word dialog box, enter the last page number of your document, then click OK. See screenshot:
Note: If you just want to save several continuously pages in document as separate pdf files such as page 4, 5 and 6, please enter 4 and 6 separately into the above two dialog boxes.
After running the code, please go to the specified folder you selected in step 4, you can see all pages are split and saved as individual pdf files as below screenshot shown.
Recommended Productivity Tools
- Complicated and repeated operations can be done a one-time processing in seconds.
- Insert multiple images across folders into Word document at once.
- Merge and combine multiple Word files across folders in to one with your desired order.
- Split the current document into separate documents according to heading 1, section break or other criteria.
- Convert files between Doc and Docx, Docx and PDF, collection of tools for common conversions and selection, and so on...