Some font attributes work and some don't

G

Greg Maxey

I am working on a macro that will change the formatting of revision in a track change document. Say the deletions are Red and strikethrough and insertions are Blue and italic.

I want to change the formatting of deletions to bold with no strikethrough and insertions as Red with stikethrough (odd choice I know). I have the following code that "does" bold the deletions and "does" strikethrough the insertions, but the other coded changes (removing strikethrough and changing color) are not working.

Can anyone offer an explanation why? Thanks.

Sub Change()
Dim oTrk As Revision
ActiveDocument.TrackRevisions = False
For Each oTrk In ActiveDocument.Range.Revisions
Select Case oTrk.Type
Case wdRevisionDelete
With oTrk.Range.Font
.Bold = True
.StrikeThrough = False
End With
Case wdRevisionInsert
With oTrk.Range.Font
.StrikeThrough = True
.Color = wdRed
End With
Case Else
'Do Nothing
End Select
Next
End Sub
 
J

Jay Freedman

Hi Greg,

The problem is that the "formatting" of revisions is completely
separate from the ordinary font formatting of the text. So when you
apply changes to oTrk.Range.Font, those changes are being added to the
revision marking, not replacing it.

The following snippet will change all the addition and deletion
marking in the whole document without having to iterate through the
Revisions collection:

With Options
.InsertedTextColor = wdRed
.InsertedTextMark = wdInsertedTextMarkStrikeThrough
.DeletedTextColor = wdAuto
.DeletedTextMark = wdDeletedTextMarkBold
End With

Things like this illustrate why it isn't enough to know how to program
in VBA to automate Word -- you also have to know the details of how
almost every feature is implemented. :-(

--
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