What macro term will accept all format changes only?

N

neutronjay

Within Track Changes I am able to manually select and accept a single format
change, but I want to be able to write a macro that will accept all format
changes at once (while leaving all text additions and deletions as is). Does
anyone know the secret phrase I'm looking for?
 
G

Greg Maxey

Might be just as easy to do it like this:

Sub Scratchmaoro()
Dim oChg As Revision
For Each oChg In ActiveDocument.Revisions
If oChg.Type = wdRevisionDelete Or oChg.Type = wdRevisionInsert Then
'Do nothing
Else
oChg.Accept
End If
Next oChg
End Sub
 
C

Charles Kenyon

Nice!

Greg Maxey said:
Might be just as easy to do it like this:

Sub Scratchmaoro()
Dim oChg As Revision
For Each oChg In ActiveDocument.Revisions
If oChg.Type = wdRevisionDelete Or oChg.Type = wdRevisionInsert Then
'Do nothing
Else
oChg.Accept
End If
Next oChg
End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
 
J

Jay Freedman

Here's your macro:

Sub AcceptAllFormatChanges()
Dim rev As Revision
For Each rev In ActiveDocument.Revisions
With rev
If .Type = wdRevisionProperty Then .Accept
End With
Next rev
End Sub

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
C

Charles Kenyon

As is often the case with help, it helps to know what you are looking for.
Looking under "revision constant" or "revision" or "constant" didn't help.
From vba Help after looking for wdRevisionDelete:
This example rejects the previous tracked change found if the change type is
deleted or inserted text. If the tracked change is a style change, the
change is accepted.

Set myRev = Selection.PreviousRevision(Wrap:=True)
If Not (myRev Is Nothing) Then
Select Case myRev.Type
Case wdRevisionDelete
myRev.Reject
Case wdRevisionInsert
myRev.Reject
Case wdRevisionStyle
myRev.Accept
End Select
End If
 
G

Greg Maxey

Jay,

I thought about that one, but I didn't have a good test document and so just
suggested to the route to explicitly ignore insertions and deletions.

Why the With/End With?
 
J

Jay Freedman

One reason is that any time I refer to two or more properties/methods
of the same object, I use a With statement. It reduces the time the
interpreter needs to dereference the object, and it also shortens the
code so it's more readable.

Another reason is that I have a code template (courtesy of an add-in
called MZ-Tools) that drops in everything except the innermost
statement with one click. :)

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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