Skip to main content

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.

Save each page as separate pdf files in bulk with VBA code


Save each page as separate pdf files in bulk with VBA code

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.


Split and save each page of a document as seperate new documents:

The Split Document utility of Kutools for Excel can help you to easily split and save each page of current document as separate new document in bulk as the below screenshot shown. Download and try it now! (60-day free trail)

Best Office Productivity Tools

Kutools for Word - Elevate Your Word Experience with Over 100 Remarkable Features!

๐Ÿค– Kutools AI Assistant: Transform your writing with AI - Generate Content  /  Rewrite Text  /  Summarize Documents  /  Inquire for Information based on Document, all within Word

๐Ÿ“˜ Document Mastery: Split Pages  /  Merge Documents  /  Export Selection in Various Formats (PDF/TXT/DOC/HTML...)  /  Batch Convert to PDF  /  Export Pages as Images  /  Print Multiple Files at once...

โœ Contents Editing: Batch Find and Replace across Multiple Files  /  Resize All Pictures  /  Transpose Table Rows and Columns  /  Convert Table to Text...

๐Ÿงน Effortless Clean: Sweap away Extra Spaces  /  Section Breaks  /  All Headers  /  Text Boxes  /  Hyperlinks  /  For more removing tools, head to our Remove Group...

โž• Creative Inserts: Insert Thousand Separators  /  Check Boxes  /  Radio Buttons  /  QR Code  /  Barcode  /  Diagonal Line Table  /  Equation Caption  /  Image Caption  /  Table Caption  /  Multiple Pictures  /  Discover more in the Insert Group...

๐Ÿ” Precision Selections: Pinpoint specific pages  /  tables  /  shapes  /  heading paragraphs  /  Enhance navigation with more Select features...

โญ Star Enhancements: Navigate swiftly to any location  /  auto-insert repetitive text  /  seamlessly toggle between document windows  /  11 Conversion Tools...

๐Ÿ‘‰ Want to try these features? Kutools for Word offers a 60-day free trial, with no limitations! ๐Ÿš€
Free Download     Read More     Buy Now
 
Comments (25)
Rated 5 out of 5 · 3 ratings
This comment was minimized by the moderator on the site
Hello,

I was wondering if there was a way to have it pull the name for the PDF from the word doc. Example: instead of Page_01, have a pull an account number that was the 3rd line down in the word document?
This comment was minimized by the moderator on the site
Hi
what if I need to set specific name for each splited PDF.
This should be taken from WORD text - it is serial korespondece- all pages have same format
Can you advise?
This comment was minimized by the moderator on the site
Hi, how would you save each pdf page as a name that can be found from within each word page being exported?
This comment was minimized by the moderator on the site
Hi, how will change the code for mac os?
This comment was minimized by the moderator on the site
Is there a way to save per 2 pages?

Ex. save page 1/2 in Page_1.pdf
save page 3/4 in Page_2.pdf

Thanks!
This comment was minimized by the moderator on the site
im wondering the same thing! please help!
This comment was minimized by the moderator on the site
Wondering the same
This comment was minimized by the moderator on the site
10x :) this was realy helpful!!!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Thanks for this, this is great. i was wondering if you have a way of naming my pdf files differently per each extract not only Page_1.pdf.

Thanks
This comment was minimized by the moderator on the site
Hi samir,
How would you like to name these pdf files? Please give me an example.
This comment was minimized by the moderator on the site
Like saving each document with a different name, not just Page_1.pdf and so on.
This comment was minimized by the moderator on the site
Hi Camila,
The following VBA code can help you solve the problem.
Note: You need to specify a different name in this line: xFileName = "AA; BB; CC; DD". Here AA, BB and CC are the names for the PDF files.
Please change them to meet your needs. You can add more names and separate them by semicolon. To mention that the number of names specified must match the number of pages you expored. And the PDF files will be named in order of the specified names in the code.
Sub SaveAsSeparatePDFs()
'Updated by Extendoffice 20221223
    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
    Dim xFileName As String
    Dim xNameArr() As String

    xFileName = "AA; BB; CC; DD"  'Specify a name for each page. The number of names specified must match the number of pages you exported.The PDF files will be named in order of the the specified names
    xNameArr = VBA.Split(xFileName, ";")
    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 & "\" & VBA.Trim(xNameArr(I - 1)) & ".pdf", _
        wdExportFormatPDF, False, wdExportOptimizeForPrint, wdExportFromTo, I, I, wdExportDocumentWithMarkup, _
        False, False, wdExportCreateHeadingBookmarks, True, False, False
    Next
    Erase xNameArr
End Sub
This comment was minimized by the moderator on the site
ะ”ะพะฑั€ั‹ะน ะดะตะฝัŒ!
ะ•ัั‚ัŒ ะปะธ ะฒะพะทะผะพะถะฝะพัั‚ัŒ ัะพั…ั€ะฐะฝะธั‚ัŒ ะธะท ะฒะพั€ะด ั„ะฐะนะปะฐ(ะธัะฟะพะปัŒะทัƒั ัะปะธัะฝะธะต) ะฒ ะฟะดั„ ั„ะฐะนะป - ะ ะตัˆะตะฝะธั ัะพะฑัั‚ะฒะตะฝะฝะธะบะพะฒ ะฝะฐ ะพะฑั‰ะตะต ัะพะฑั€ะฐะฝะธะต.
ะŸั€ะธ ัั‚ะพะผ ัƒั‡ะธั‚ั‹ะฒะฐะตะผ, ั‡ั‚ะพ PDF ะดะพะปะถะตะฝ ัะพั…ั€ะฐะฝัั‚ัŒัั ั‚ะฐะบ: ะฒ 1 ั„ะฐะนะปะต ะดะพะปะถะฝะพ ะฑั‹ั‚ัŒ ะฝะตัะบะพะปัŒะบะพ ะปะธัั‚ะพะฒ (1 ะบะฒะฐั€ั‚ะธั€ะฐ), ะฟะพ ะดะฐะฝะฝะพะผัƒ ะผะพะดัƒะปัŽ ัั‚ั€ะฐะฝะธั†ั‹ ัะพั…ั€ะฐะฝััŽั‚ัั ะฒ ะฟะดั„, ะฝะพ ั€ะฐะทะดะตะปัŒะฝะพ
This comment was minimized by the moderator on the site
Hi,
Sorry I don't understand what you mean. You may need to attach a screenshot or a sample file to describe the problem you encountered more clearly.
This comment was minimized by the moderator on the site
Thanks for the script, it has also saved me a lot of work in exporting pages as pdf!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Reading these instructions has helped me to complete a project that would've taken 2 or more hours, in 20 minutes. Thank you so much!
Rated 5 out of 5
This comment was minimized by the moderator on the site
Hi Kyle Baldwin,
It would be our pleasure to help solve your problem.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
Rate this post:
0   Characters
Suggested Locations