跳至主要内容

Kutools for Office — 一套工具,五种功能。事半功倍。

如何将Word文档中的每一页保存为单独的PDF文件?

Author: Siluvia Last Modified: 2025-08-22

在 Microsoft Word 中,您可以手动使用内置的“另存为”功能,并在“选项”对话框中指定页码,从而将每一页保存为单独的 PDF 文件。然而,如果您正在处理包含数百页的大型文档,手动执行此操作可能会非常耗时。本文介绍了一种快速将所有页面保存为单独 PDF 文件的方法。

使用VBA代码批量将每一页保存为单独的PDF文件


使用VBA代码批量将每一页保存为单独的PDF文件

您可以使用以下 VBA 代码自动将 Word 文档中的每一页保存为单独的 PDF 文件。具体操作如下:

  1. 打开要处理的 Word 文档。按 Alt + F11 打开 Microsoft Visual Basic for Applications 窗口。
  2. 在 Visual Basic 窗口中,点击“插入”>“模块”,然后将以下 VBA 代码粘贴到模块窗口中:
    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
    VBA window with Insert > Module selected and VBA code copied into the Module window
  3. F5 运行代码。
  4. 在弹出的浏览窗口中,选择一个文件夹以保存 PDF 文件,然后点击“确定”。
    Browse window
  5. 在第一个“Kutools for Word”对话框中,输入起始页码并点击“确定”。
    Kutools for Word dialog box with a text box for entering the start page number
  6. 在第二个“Kutools for Word”对话框中,输入结束页码并点击“确定”。
    Second Kutools for Word dialog box with a text box for entering the last page number

    注意:例如,要保存几页连续的页面——第4、5和6页,只需在两个对话框中分别输入“4”和“6”。

脚本运行完成后,转到您在第4步中选择的文件夹。您会发现每个指定的页面都已保存为单独的 PDF 文件:

Pages are split and saved as individual PDF files

轻松将Word文档拆分为多个文档
使用文档拆分工具,轻松将Word文档拆分为多个文档。无需手动复制粘贴,该工具允许您根据页面标题 1分页符分节符来拆分文档,大幅提升效率。
A screenshot of the Split Document utility splitting a Word document by page
Kutools for Word:通过数百种便捷工具增强您的Word体验。立即下载并体验差异!

最佳Office办公效率工具

Kutools for Word - 用超过100项强大功能全面提升你的Word体验!

🤖 Kutools AI 功能AI助手 / 实时助手 / 超级润色(保留格式)/ 超级翻译(保留格式)/ AI遮挡 / AI校正……

📘 文档掌控分割页面 / 文档合并 / 区域导出为多种格式(PDF/TXT/DOC/HTML等)/ 批量转换为PDF……

正文编辑跨多个文件批量查找与替换 / 一键调整所有图片大小 / 翻转表格行列 / 表格转文本……

🧹 高效清理:一扫多余空格 / 分节符 / 文本框 / 超链接 / 想了解更多删除工具,请前往删除分组……

创意插入:插入千位区分符 /复选框 /选项按钮 / 二维码 / 条形码 / 批量插入图片 / 更多内容请见插入分组……

🔍 精准选取:快速定位指定页面 / 表格 / 形状 / 标题段落 / 利用更多 选择 功能提升导航体验……

实用增强跳转任意区域 / 自动插入重复文本 / 文档窗口间一键切换 /11 转换工具……

🌍 支持40多种语言:自由选择你喜欢的界面语言——Kutools支持英语、西班牙语、德语、法语、中文及其他40余种语言!

Kutools and Kutools Plus tabs on the Word Ribbon
👉 想立即体验这些功能?马上下载 Kutools for Word!🚀
 

✨ Kutools for Office – 一次安装,五大强力工具集成!

内含 Office Tab Pro · Kutools for Excel · Kutools for Outlook · Kutools for Word · Kutools for PowerPoint

📦 五大工具一站式集成 | 🔗 无缝兼容Microsoft Office | ⚡立即提升效率、节省时间

最佳Office办公效率工具

Kutools for Word - 100+ 项Word工具