VBA Replacing Highligted text with other text in WORD
3 views
Skip to first unread message
Neeraj Shinde
unread,
Jun 4, 2005, 5:44:37 AM6/4/05
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ProgrammingGuru
My VBA Code :
________________________________________
Sub ReplaceHighlightedText()
Dim Hran As Range Set Hran =
ActiveDocument.Range ''Replaces the highlighted text with
Specific text nextsearch: With
Hran.Find
'.Text =
Harr(1)
.Forward =
True .Wrap
=
wdFindAsk
.Highlight =
True .Wrap
=
wdFindStop
.Execute
If Hran.Find.Found = True
Then
Hran.Select
With
ActiveDocument.Application.Selection
Select Case
.Range.HighlightColorIndex
Case 4
'green
.Text =
"author="""""
.Range.HighlightColorIndex =
wdNoHighlight
Case 3
'blue
.Text =
"title="""""
.Range.HighlightColorIndex =
wdNoHighlight
Case 5
'pink
.Text = "<roman num=""19""
type=""century""/><sup>e</sup>"
.Range.HighlightColorIndex =
wdNoHighlight
Case 15
'ARCU
.Text =
"<initials>ARCU</initials>"
.Range.HighlightColorIndex =
wdNoHighlight
Case 7
'yellow
.Text =
"<insertion>arcu</insertion>"
.Range.HighlightColorIndex =
wdNoHighlight
End
Select
End
With
Hran.Start = ActiveDocument.Application.Selection.Range.End +
1
Hran.End =
ActiveDocument.Range.End
GoTo
nextsearch
End If End With