Solved

Word:VBA - Progammically changing tracking settings

Posted on 2004-04-29
12
1,118 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Like many others, we try and discourage users from printing documents unnecessarily and instead send or share them electronically. However, this doesn't always work and documents are still printed. With this simple solution, if the user tries to …
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

785 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