Solved

Word:VBA - Progammically changing tracking settings

Posted on 2004-04-29
12
1,123 Views
Last Modified: 2008-02-01
Here is a problem that I do not know can be done.  I need to programmically (vba) change the tracking characteristics.  For example, I need to change the red characters to bold.  Is there a way that I can programmically change the settings and then change them back again?
0
Comment
Question by:DCCoolBreeze
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 10959693
The easiest way to do this is to open the document, record a macro, doing a search and replace for red text, replace it with bold.

Here's something like it would look:

Sub RedToBold()
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Font.Color = wdColorRed
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Bold = True
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
0
 
LVL 1

Author Comment

by:DCCoolBreeze
ID: 10961544
OK.  I tried that but it did not work.  I will not change the RED tracking fonts to black bold.  See I have tracking on.  What I need to do is copy and paste that document into a application that does not understand colors.  How do I manipulate the tracking corrections.
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 10961858
Sorry - I forgot a line:

Sub RedToBlack()
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Font.Color = wdColorRed
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.Font
        .Bold = True
        .Color = wdColorAutomatic
    End With
    With Selection.Find
        .Text = ""
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:DCCoolBreeze
ID: 10962705
nope...still no luck.  The macro will change document text but I am trying to change the "Red Tracking Font words".  When change tracking is enabled, you get the changes in red.  These "red" changes are what I want to change.  The are displayed on the screen and they can be sent to the printer...so there must be a way to change the "red strikouts" or "red underlines" to "black bold strikeouts" or "black bold underlines"
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 10963049
The macro I gave you will change the red changes to black/bold...what are you using to track changes?  Word?  If you're using DeltaView, that program uses styles and you'll need a completely different solution.

If you want the red strikeouts and the red underlines (are they double underline?), we can give you a macro for all that too...but I was just getting your started.  I didn't expect my macro to do the whole thing for you.  Not being able to see what your tracking options are leaves me at a bit of a disadvantage.


Sorry - I think I see what you're talking about...will get to you in a few
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 10963222
One thing to do is go to Tools, Options, Revisions, and change your options from red to black.  I'm now trying to figure out how to get it bolded.
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 10963575
Ok - well I'm stumped.  I believe I used to be able to do this in 97 but I'm using 2000 now.  When I create a document with track changes, and the text is shown as strikethrough, then I go to Format, Font, no strikethrough is shown.  Same with underlined...very strange.  My normal method would be to search and replace but you can't search and replace what's not shown under the formatting...hmmmm

Can you use any other method?  Compare documents?  CompareRite?  DeltaView?

0
 
LVL 100

Expert Comment

by:mlmcc
ID: 10967728
In Word97 the following macro should change your tracking changes to bold
Sub Macro2()
'
' Macro2 Macro
' Macro recorded 05/01/04 by MM
'
    With Options
        .InsertedTextMark = wdInsertedTextMarkBold
        .InsertedTextColor = wdRed
        .DeletedTextMark = wdDeletedTextMarkStrikeThrough
        .DeletedTextColor = wdByAuthor
        .RevisedPropertiesMark = wdRevisedPropertiesMarkNone
        .RevisedPropertiesColor = wdAuto
        .RevisedLinesMark = wdRevisedLinesMarkOutsideBorder
        .RevisedLinesColor = wdAuto
    End With
    With ActiveDocument
        .TrackRevisions = True
        .PrintRevisions = True
        .ShowRevisions = True
    End With
End Sub


Word97 doen't have an option for BOLD & UNDERLINE

mlmcc
0
 
LVL 37

Assisted Solution

by:Joanne M. Orzech
Joanne M. Orzech earned 250 total points
ID: 10967770
DCCoolBreeze - I've enlisted the help of all experts on EE to help resolve your problem.  Looks like we might have a solution! Many thanks Michael.
0
 
LVL 24

Accepted Solution

by:
R_Rajesh earned 250 total points
ID: 10968615
You might also want to consider making use of the document's revisions property.

Open your document with revisions, make sure the current view is showing the revisions, hit alt+f11, this opens the vbe window, here select module form the insert menu and paste the code below. Close the vbe window, back in word hit alt+f8, select customTc and click on run.

The code creates a duplicate document, goes through each revisions in the document. It bolds all the revisions (red text), underlines all the tracked additions (red underlines) and strikes all the tracked deletions (red strikethrough)

'-------------------
Sub customTC()
Dim wDoc As Word.Document, tDoc As Document, mrev As Revision
Set tDoc = ActiveDocument
If tDoc.TrackRevisions = True Then
Set wDoc = Documents.Add
wDoc.Content = tDoc.Content
For Each mrev In tDoc.Revisions
With wDoc.Range(mrev.Range.Start, mrev.Range.End).Font
.Size = .Size + 1: .Bold = True
.StrikeThrough = (mrev.Type = 2): .Underline = (mrev.Type = 1)
End With
Next mrev
End If
Set wDoc = Nothing: Set tDoc = Nothing
End Sub
'--------------------

Rajesh
0
 
LVL 1

Author Comment

by:DCCoolBreeze
ID: 10976550
Wow.  Thanks for the help...I will try the solution this morning...
0
 
LVL 24

Expert Comment

by:R_Rajesh
ID: 10982668
thanks for the grade, DCCoolBreeze
:)
Rajesh
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question