Input Font, as I have to fonts 10.5 and 12

SteveD 625 Reputation points
2026-06-10T21:53:09.0033333+00:00

Hello from Steve

In the below script I would like to add please Font 12

Sub Rename_Trainers()

Dim FindArray As Variant

Dim ReplArray As Variant

Dim i As Long

FindArray = Array("MCKAY HARRINGTO", "RICHARDSON NORV", "D & B WEATHERLE", "THURLOW O'MALLE", "WALKER BERGERSO", _

"O'SULLIVAN SCOT")

ReplArray = Array("MCKAY HARRINGTON", "RICHARDSON NORVALL", "D & B WEATHERLEY", "THURLOW O'MALLEY", "WALKER BERGERSON", _

"O'SULLIVAN SCOTT")

For i = LBound(FindArray) To UBound(FindArray)

    With ActiveDocument.Content.Find

        .ClearFormatting

        .Replacement.ClearFormatting

        .Text = FindArray(i)

        .Replacement.Text = ReplArray(i)

        .Forward = True

        .Wrap = wdFindContinue

        .Format = True

        .MatchCase = True

        .MatchWholeWord = True

        .MatchWildcards = False

        .MatchSoundsLike = False

        .MatchAllWordForms = False

        .Execute Replace:=wdReplaceAll

    End With

Next i

End Sub

Microsoft 365 and Office | Word | For home | Windows
0 comments No comments

Answer accepted by question author

AI answer

2026-06-10T21:53:16.89+00:00

Add formatting for the replacement text by setting the Font.Size on the Replacement formatting before executing Find.Execute.

For example, to make all replaced trainer names use font size 12:

Sub Rename_Trainers()

    Dim FindArray As Variant
    Dim ReplArray As Variant
    Dim i As Long

    FindArray = Array("MCKAY HARRINGTO", "RICHARDSON NORV", "D & B WEATHERLE", _
                      "THURLOW O'MALLE", "WALKER BERGERSO", "O'SULLIVAN SCOT")

    ReplArray = Array("MCKAY HARRINGTON", "RICHARDSON NORVALL", "D & B WEATHERLEY", _
                      "THURLOW O'MALLEY", "WALKER BERGERSON", "O'SULLIVAN SCOTT")

    For i = LBound(FindArray) To UBound(FindArray)
        With ActiveDocument.Content.Find
            .ClearFormatting
            .Replacement.ClearFormatting

            .Text = FindArray(i)
            .Replacement.Text = ReplArray(i)

            ' Apply font size 12 to the replacement text
            .Replacement.Font.Size = 12

            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = True
            .MatchWholeWord = True
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False

            .Execute Replace:=wdReplaceAll
        End With
    Next i

End Sub

This keeps the existing find/replace behavior and ensures that each replaced name is formatted with font size 12.


References:

AI-generated content may be incorrect. Read our transparency notes for more information.

Was this answer helpful?

2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.