VBA for Track Changes

N

Nora

Hi,
I'm trying to write code that will accept all insertions
and reject all deletions automatically after comparing
and merging documents. Right now, my code compares and
merges the documents. So I have a final document with
all kinds of insertions and deletions, etc.

The only way I can code it right now is to accept all
changes or reject all changes, but I need to to do accept
some and reject others.

Any suggestions would be much appreciated!

Thanks in advance!
 
H

Helmut Weber

Hi Nora,
how about this as a very basic start for working
with the revisions object:
---
Sub test2()
Dim oRvs As Revision
Dim iRsl As Integer
For Each oRvs In ActiveDocument.Revisions
If oRvs.Type = wdRevisionDelete Then
iRsl = MsgBox(oRvs.Range.Text, 3, "Deletion")
Select Case iRsl
Case 6: oRvs.Accept
Case 7: oRvs.Reject
End Select
End If
If oRvs.Type = wdRevisionInsert Then
iRsl = MsgBox(oRvs.Range.Text, 3, "Insertion")
Select Case iRsl
Case 6: oRvs.Accept
Case 7: oRvs.Reject
End Select
End If
Next
End Sub
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Nora > écrivait :
In this message, < Nora > wrote:

|| Hi,
|| I'm trying to write code that will accept all insertions
|| and reject all deletions automatically after comparing
|| and merging documents. Right now, my code compares and
|| merges the documents. So I have a final document with
|| all kinds of insertions and deletions, etc.
||
|| The only way I can code it right now is to accept all
|| changes or reject all changes, but I need to to do accept
|| some and reject others.
||
|| Any suggestions would be much appreciated!
||
Play around with this code to get you going:

'_______________________________________
Dim CurRange As Range 'To save user starting selection point
Dim MyChange As Revision

Set CurRange = Selection.Range

For Each MyChange In ActiveDocument.Revisions
With MyChange
If .Type = wdRevisionDelete Then
.Reject
ElseIf .Type = wdRevisionInsert Then
.Accept
Else
.Range.Select
If MsgBox("This is neither a deletion or an insertion." _
& vbCrLf & "Click ""OK"" to accept this revision.", _
vbOKCancel, "Accept revision?") = 1 Then
.Accept
Else
.Reject
End If
End If
End With
Next MyChange

CurRange.Select
'_______________________________________

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top