charliew001
09-06-2012, 09:02 PM
Hi all,
I have a list of words that need to be italicized in all word documents. Normally, I would copy and paste the below macro to include each word, which in this case are all bacteria. But in an attempt to learn learn more VB, I was hoping to get some help on creating a script that find words that I specified in a word document, or rather just not coded into the script, and italicize the words in the active document which match the words in the aforementioned list.
Thanks
Sub Italicize1()
'
' Italicize1 Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Italic = True
With Selection.Find
.Text = "S. pneumoniae"
.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
I have a list of words that need to be italicized in all word documents. Normally, I would copy and paste the below macro to include each word, which in this case are all bacteria. But in an attempt to learn learn more VB, I was hoping to get some help on creating a script that find words that I specified in a word document, or rather just not coded into the script, and italicize the words in the active document which match the words in the aforementioned list.
Thanks
Sub Italicize1()
'
' Italicize1 Macro
'
'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Italic = True
With Selection.Find
.Text = "S. pneumoniae"
.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