Italics for many phrases in Word


Mustang 15

I've been writing code that finds and replaces words to make it italic. However, I can't figure out how to use arrays for efficiency. Currently, my code is what I've been copying and pasting with loops:

    Sub ItalicsText()
'
' ItalicsText Macro
'
'
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Italic = True
    With Selection.Find
        .Text = "Lord of the Rings"
        .Replacement.Text = "Lord of the Rings"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
        Selection.Find.Execute Replace:=wdReplaceAll
    Selection.EscapeKey
End Sub

However, I want to do this so that I can have an array like this:

vFindText = Array("Lord of the Rings", "blah", "blah")

I'm doing this because I'm checking hundreds of phrases and want to make it faster to encode.

Tim Williams

Untested:

Sub AllTexts()
    Dim vFindText, v
    vFindText = Array("Lord of the Rings", "blah", "blah")
    For Each v in vFindText 
        ItalicsText v
    Next v
End Sub


Sub ItalicsText(findWhat)

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Italic = True
    With Selection.Find
        .Text = findWhat
        .Replacement.Text = findWhat
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Selection.EscapeKey
End Sub

Related


Italics for many phrases in Word

Mustang 15 I've been writing code that finds and replaces words to make it italic. However, I can't figure out how to use arrays for efficiency. Currently, my code is what I've been copying and pasting with loops: Sub ItalicsText() ' ' ItalicsText Macro '

Atom editor italics the word REVIEW in blue - how to disable?

stacker The Atom editor italicizes the word REVIEW in blue. Why? My text format is selected as "Plain Text". There should not be any syntax format. How to disable this feature? It only happens when the letters are all capital letters like this REVIEW. Is this

Atom editor italics the word REVIEW in blue - how to disable?

stacker The Atom editor italicizes the word REVIEW in blue. Why? My text format is selected as "Plain Text". There should not be any syntax format. How to disable this feature? It only happens when the letters are all capital letters like this REVIEW. Is this

Atom editor italics the word REVIEW in blue - how to disable?

stacker The Atom editor italicizes the word REVIEW in blue. Why? My text format is selected as "Plain Text". There should not be any syntax format. How to disable this feature? It only happens when the letters are all capital letters like this REVIEW. Is this

Atom editor italics the word REVIEW in blue - how to disable?

stacker The Atom editor italicizes the word REVIEW in blue. Why? My text format is selected as "Plain Text". There should not be any syntax format. How to disable this feature? It only happens when the letters are all capital letters like this REVIEW. Is this

Atom editor italics the word REVIEW in blue - how to disable?

stacker The Atom editor italicizes the word REVIEW in blue. Why? My text format is selected as "Plain Text". There should not be any syntax format. How to disable this feature? It only happens when the letters are all capital letters like this REVIEW. Is this