提示:其它语言是由 Google 机器翻译的。 你可以访问 English 版本。
登录
x
or
x
x
马上登记
x

or

如何将Word文档拆分为每个5或n个页面的单独文件?

如果您有一个包含数百页的大型Word文档,现在,您希望将此文档拆分为每个10或n个页面的单独文件。 有没有快速简便的方法来解决这个问题,而无需逐个复制和粘贴页面?

使用VBA代码将每个10或n个页面的Word文档拆分为单独的文件

使用Kutools for Word将每个1页面的Word文档拆分为单独的文件


根据每个页面将Word文档拆分为单独的文件:

您订购的 Kutools for Word's 分裂 功能,您可以根据Heading1,分页符,分节符和页面快速将大型Word文档拆分为多个单独的文件。

每n页9分开一次doc

Kutools for Word:拥有超过100便利的Word插件,可以免费试用60时间不受限制。 点击下载并免费试用现在!


使用VBA代码将每个10或n个页面的Word文档拆分为单独的文件

要根据每个10或n个页面将大文档拆分为单独的文件,以下VBA代码可以帮到您,请按以下步骤操作:

1。 按住 ALT + F11 键打开 Microsoft Visual Basic for Applications 窗口。

2。 然后点击 插页 > 模块,将下面的代码复制并粘贴到打开的空白模块中:

VBA代码:每个10或n个页面将文档拆分为单独的文件:

Sub DocumentSplitter()
    Dim xDoc As Document, xNewDoc As Document
    Dim xSplit As String, xCount As Long, xLast As Long
    Dim xRngSplit As Range, xDocName As String, xFileExt As String
    Dim xRegEx As RegExp
    Dim xPageCount As Integer
    Dim xShell As Object, xFolder As Object, xFolderItem As Object
    Dim xFilePath As String
    On Error Resume Next
    Set xDoc = Application.ActiveDocument
    Set xShell = CreateObject("Shell.Application")
    Set xFolder = xShell.BrowseforFolder(0, "Select a Folder:", 0, 0)
    If TypeName(xFolder) = "Nothing" Then Exit Sub
    Set xFolderItem = xFolder.Self
    xFilePath = xFolderItem.Path & "\"
    Application.ScreenUpdating = False
    Set xNewDoc = Documents.Add(Visible:=False)
    xDoc.Content.WholeStory
    xDoc.Content.Copy
    xNewDoc.Content.PasteAndFormat wdFormatOriginalFormatting
    With xNewDoc
        xPageCount = .ActiveWindow.Panes(1).Pages.Count
L1:     xSplit = InputBox("The document contains " & xPageCount & " pages." & _
                 vbCrLf & vbCrLf & " Please enter the page count you want to split:", "Kutools for Word", xSplit)
        If Len(Trim(xSplit)) = 0 Then Exit Sub
        Set xRegEx = New RegExp
        With xRegEx
            .MultiLine = False
            .Global = True
            .IgnoreCase = True
            .Pattern = "[^0-9]"
        End With
        If xRegEx.Test(xSplit) = True Then
            MsgBox "Please enter the page number:", vbInformation, "Kutools for Word"
            Exit Sub
        End If
        If VBA.Int(xSplit) >= xPageCount Then
            MsgBox "The number is greater than the document number." & vbCrLf & "Please re-enter", vbInformation, "Kutools for Word"
            GoTo L1
        End If
        xDocName = xDoc. Name
        xFileExt = VBA.Right(xDocName, Len(xDocName) - InStrRev(xDocName, ".") + 1)
        xDocName = Left(xDocName, InStrRev(xDocName, ".") - 1) & "_"
        xFilePath = xFilePath & xDocName
        For xCount = 0 To Int(xPageCount / xSplit)
            xPageCount = .ActiveWindow.Panes(1).Pages.Count
            If xPageCount > xSplit Then
                xLast = xSplit
            Else
                xLast = xPageCount
            End If
            Set xRngSplit = .GoTo(What:=wdGoToPage, Name:=xLast)
            Set xRngSplit = xRngSplit.GoTo(What:=wdGoToBookmark, Name:="\page")
            xRngSplit.Start = .Range.Start
            xRngSplit.Cut
            Documents.Add
            Selection.Paste
            ActiveDocument.SaveAs FileName:=xFilePath & xCount + 1 & xFileExt, AddToRecentFiles:=False
            ActiveWindow.Close
        Next xCount
        Set xRngSplit = Nothing
        xNewDoc.Close wdDoNotSaveChanges
        Set xNewDoc = Nothing
    End With
    Application.ScreenUpdating = True
End Sub

3。 粘贴上面的代码后,仍然在 Microsoft Visual Basic for Applications 窗口,请点击 > 参考文献,并在弹出 参考项目 对话框,检查 Microsoft VBScript正则表达式5.5 在选项 可用的参考 列表框,看截图:

每n页1分开一次doc

4。 然后点击 OK 按钮,然后按 F5 运行这个代码的关键,和一个 浏览文件夹 显示对话框,请选择要将拆分文件放入的文件夹,请参见屏幕截图:

每n页2分开一次doc

5。 然后点击 OK 按钮,弹出另一个提示框,提醒您输入要拆分的页数,请参见屏幕截图:

每n页3分开一次doc

6。 然后点击 OK 按钮,活动的Word文档已经被拆分成每个10页面的单独文件,你可以去指定的文件夹中查看结果:

每n页4分开一次doc


使用Kutools for Word将每个1页面的Word文档拆分为单独的文件

Kutools for Word 包括一个强大的功能 - 分裂 功能,使用此实用程序,您可以根据Heading1,分页符,分节符和页面快速将大型Word文档拆分为多个单独的文件。

Kutools for Word : 有超过100便利的Word插件,可以在60天免费试用而没有限制.

安装后 Kutools for Word,请这样做:

1。 点击 企业服务 > 分裂,看截图:

每n页5分开一次doc

2。 在弹出 分割文件 对话框,单击 每n页7分开一次doc 按钮选择要放置拆分文件的文件夹,然后选择 来自 拆分 下拉列表,看截图:

每n页6分开一次doc

3。 完成设置后,请点击 OK,整个文档将根据每个页面拆分成多个文件,请参见截图:

每n页8分开一次doc

点击下载Kutools for Word并免费试用!




推荐的Word生产力工具

Kutools For Word - 超过100 Word的高级功能,节省您的50%时间

  • 复杂和重复的操作可以在几秒钟内完成一次性处理。
  • 一次将多个图像跨文件夹插入Word文档。
  • 将多个文件夹合并并组合成一个具有所需订单的文件。
  • 根据标题,分节符或其他标准将当前文档拆分为单独的文档。
  • 在Doc和Docx,Docx和PDF之间转换文件,用于常见转换和选择的工具集合等等......
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Mike · 3 months ago
    For me, the VBA creates a single document that is a copy of the original and that's it.
  • To post as a guest, your comment is unpublished.
    Studia · 3 months ago
    The VBscript code made Word crash. I was trying to split a 32Mb Word file with many pages but it seems Word can't handle it through VBscript.
    Thanks anyway
    • To post as a guest, your comment is unpublished.
      skyyang · 3 months ago
      Hello, Studia,
      The VBA code may crash when there is a large document, it is not stable, so I recommend you use our Kutools for Word tool, it has updated, and support to solve this task, you can download it and free trial 30 day.
      Please try, thank you!
  • To post as a guest, your comment is unpublished.
    Sergey · 4 months ago
    VBA Script: Split a document into separate files every 10 or n pages not worked
    • To post as a guest, your comment is unpublished.
      skyyang · 4 months ago
      Hello, Sergey,
      The above code works well in my Word document, which Word version do you use?
      And which step went wrong in your operation?
  • To post as a guest, your comment is unpublished.
    Lena · 6 months ago
    i have been trying to split a word file of 166 pages and it gives 166 files each with 166 pages?