问题描述
我希望在审阅后从Word文档中提取插入和删除的文本.我已经可以使用以下宏提取注释:
I'm looking to extract the inserted and deleted text from a word document after it's been reviewed. I've been able to extract the comments using the following macro:
Sub ExportComment()
Dim s As String
Dim cmt As Word.Comment
Dim doc As Word.Document
Dim workBk As Word.Document
Set workBk = ActiveDocument
Set doc = Documents.Add(Visible:=True)
Dim myRange As Range
Set myRange = doc.Range(0, 0)
Dim myTable As Table
Set myTable = doc.Tables.Add(Range:=myRange, NumRows:=workBk.Comments.Count, NumColumns:=6)
Dim i As Integer
i = 1
For Each cmt In workBk.Comments
myTable.Cell(i, 1).Range.Text = cmt.Index
myTable.Cell(i, 2).Range.Text = cmt.Scope.Information(wdActiveEndPageNumber)
myTable.Cell(i, 3).Range.Text = cmt.Initial
myTable.Cell(i, 4).Range.Text = cmt.Scope
myTable.Cell(i, 5).Range.Text = cmt.Range.Text
i = i + 1
Next
End Sub
但是似乎无法弄清楚如何从跟踪的更改中获取插入和删除的文本.有什么想法吗?
But can't seem to figure out how to also get the inserted and deleted text from the tracked changes. Any ideas?
谢谢!
推荐答案
就像在示例代码中使用Comments
集合一样,您将要使用Revisions
集合(例如Dim rev as Word.Revision
).与Comments
不同,Revisions
具有Type属性,可用于标识不同的Track Changes.以下是一些修订类型:
Just as you used the Comments
collection in your sample code, you will want to use the Revisions
Collection (for example, Dim rev as Word.Revision
). Unlike Comments
, Revisions
has a Type property that you can use to identify different varieties of Track Changes. Here are some revision types:
如果要查看提取修订的示例VBA代码,请转到
If you want to see example VBA code that extracts revisions, go to
http://www.thedoctools.com/downloads/basTrackChanges_Extract.shtml
在讨论提取修订的问题时,在下一页中引用了
:
which is referenced on the below page while discussing the issue of extracting revisions:
http://www.thedoctools.com/index.php?show=mt_trackchanges_extract
这篇关于从docx文件中提取跟踪更改信息(插入已删除的文本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!