从 Word 文档中提取单个页面的 2 种快速方法

在今天的ost,我们想与您分享 2 种从 Word 文档中提取单个页面的快速方法。

有时在Word文档中,每一页可能包含相当独立的内容,例如表格。 您可能需要将不同的表格发送给不同的人。 然后,您必须将每个页面的每个表格保存为一个单独的文件。

我们想到的第一个想法应该是经典的复制粘贴。 然而,任何涉及选择的事情有时都会很烦人,因为拖动和选择可以很容易地在没有选择的情况下结束。 为此,我们向您推荐 2 种使用宏的快速方法来完成这项工作。

方法 1:提取当前页面并将其另存为新文档

首先和形式ost, 将光标定位在要提取的页面上。

单击“开发人员”选项卡,然后单击“Visual Basic”以调用 VBA 编辑器。 如果未激活“开发人员”,只需按“Alt+F11”即可。

其次,点击“普通”项目。

接下来单击“插入”选项卡并选择“模块”。

双击新模块打开编辑区。

然后将以下代码粘贴到那里:

Sub SaveCurrentPageAsANewDoc()

Dim objNewDoc As Document

Dim objDoc As Document

Dim strFileName As String

Dim strFolder As String

' Initialization

Set objDoc = ActiveDocument

strFolder = InputBox("Enter folder path here: ")

strFileName = InputBox("Enter file name here: ")

' Copy current page.

objDoc.Bookmarks("\Page").Range.Select

Selection.Copy

' Open a new document to paste the selection.

Set objNewDoc = Documents.Add

Selection.Paste

objNewDoc.SaveAs FileName:=strFolder & "\" & strFileName & ".docx"

objNewDoc.Close

End Sub

最后,单击“运行”按钮。

现在会有2个输入框。 在第一个输入框输入你要存放新文档的路径。 并在第二个上输入新的文档名称。

方法 2:提取每个页面并将其另存为新文档

以下宏将使您能够提取文档的每一页。

首先,按“Ctrl+Home”转到文档的开头。

然后按照方法 1 中的相同步骤安装并运行宏。

这次用这个替换宏:

Sub SaveEachPageAsADoc()

Dim objNewDoc As Document

Dim objDoc As Document

Dim nPageNumber As Integer

Dim strFolder As String

Dim objFileName As Range

' Initialization

Set objDoc = ActiveDocument

strFolder = InputBox("Enter folder path here: ")

' Copy each page in the document to paste it into a new one.

For nPageNumber = 1 To ActiveDocument.ComputeStatistics(wdStatisticPages)

Application.Browser.Target = wdBrowsePage

ActiveDocument.Bookmarks("\page").Range.Select

Selection.Copy

Set objNewDoc = Documents.Add

Selection.Paste

' Save new doc with the name of "Page" & nPageNumber and get the first 20 characters of the new doc as part of the file name.

Set objFileName = objNewDoc.Range(Start:=0, End:=20)

objNewDoc.SaveAs FileName:=strFolder & "\" & "Page " & nPageNumber & " " & objFileName & ".docx"

objNewDoc.Close

Application.Browser.Next

Next nPageNumber

End Sub

处理单词问题

存在并且总是会出现各种 Word 问题。 关键是学会正确修复它们。 他们ost 当然,推荐的方法是获得一个复杂的 单词恢复 工具。 您应该抓紧每一分钟恢复数据,以免为时已晚。

作者简介:

Vera Chen 是一位数据恢复专家 DataNumen, Inc.,它是数据恢复技术领域的世界领先者,包括 损坏的 xlsx 和 pdf 修复软件产品。 欲了解更多信息,请访问 datanumen.com