Hi All,
I am facing issues with the word macro that I have created. I have created a macro to change the font and formatting of specific words mentioned in the inputbox. I am facing two issues:
1. The macro works well when I use Alt +F8. However whenever I am adding a macro button it doesnt seem to highlight the input text.
2. Can we add multiple words in the input box (seperated by a space) and all get highlighted at once, instead of running the macro again for different set of words again and again.
I have used the following code:
Sub Wordhighlighter()
'
' Highlights words of specific interest to you'
MyInput = inputbox("Please enter the words which you want to highlight")
Selection.Find.ClearFormatting
With Selection.Find
.Text = MyInput
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = False
With Selection.Find.Replacement.Font
.Italic = True
.Color = wdColorRed
.Bold = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Bookmarks