Find and replace with VBA in Word

Hi,

I would like a macro to find a specific character in a word document. From that character and to the end of the line I want to change color of the text. Any ideas how to achieve this?

Ex.

''' sfgsjfhgjhsdhughurhui

dfsjngjnsfn ''' asdjgrffkjn

should after running the macro look like

''' sfgs jfh gjhsdh ughurhui

dfsjngjnsfn''' asdjgrffkjn

Thankful for help

Jonas

[509 byte] By [JS] at [2008-1-10]
# 1

Hi!

Try this

Code Block
Sub ColorLine()
Dim flag As Boolean
Dim strF As Integer
Dim strS As Integer
ActiveDocument.Range(ActiveDocument.Characters.Count - 1) = _
ActiveDocument.Range(ActiveDocument.Characters.Count - 1)
Do
Selection.Find.ClearFormatting
With Selection.Find
.text = "'''"
.Replacement.text = ""
.Forward = True
.Wrap = wdFindContinue
.Execute
If .Found = False Then Exit Do
End With
strS = Selection.End
If flag = True And strS = strF Then Exit Do
If flag = False Then strF = Selection.End
ActiveDocument.Range(Selection.Start, Selection.GoTo(wdGoToLine, wdGoToRelative, 1).Start - 1).Font.Color = wdColorRed
flag = True
Loop
End Sub

bi-lya at 2007-10-3 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...