Tuesday, December 18, 2007

Macro to copy red font text

Dec. 19, 2007

Macro that assists in translating parts of a document

I have a client that marks parts of large Word documents in red font and asks me to translate them. This is because the rest of the text has already been translated.

I wrote a macro with the help of a Word MVP called CopyFontRed. This macro selects all the text in red and copies it to a separate Word document. You can quickly do a character/word count of only the text that you need to translate and prepare an estimate. Drag this macro also to your menu bar and place it there, as explained in yesterday's macro. You can change Red to Blue, for instance, in the macro below, if you wish to dump blue text to a separate file. Here it is; enjoy!

Sub CopyFontRedText()

' Date 01/04/11 Recorded by Gururaj Rao

' Copies Red Text to a Separate File


Dim SourceDoc As Document, Target As Document, FontColorIndex As String

On Error GoTo Endit

Set SourceDoc = ActiveDocument

Set Target = Documents.Add



Selection.Find.Font.ColorIndex = wdRed

With Selection.Find

.Text = ""

.Replacement.Text = ""

.Forward = True

.Wrap = wdFindContinue

.Format = True

.MatchCase = False

.MatchWholeWord = False

.MatchWildcards = False

.MatchSoundsLike = False

.MatchAllWordForms = False

End With

While Selection.Find.Execute = True

FontColorIndex = Selection.Text

Target.Range.InsertAfter FontColorIndex & vbCr




Exit Sub

End Sub

No comments: