Share via

word Font Input

Anonymous
2024-09-03T21:16:58+00:00

Hello from Steve

I have two fonts 14.5 and 10.5

Can the below script have Font 14.5 only please

Sub Track_Names2()

Dim range As range

Dim i As Long

Dim TargetList

TargetList = Array("AWAPUNI SYNTHETIC", "HAWERA", "ASCOT PARK", "HASTINGS", "PUKEKOHE", "NEW PLYMOUTH", "RICCARTON", _

"PHAR LAP", "WAVERLEY", "ROTORUA", "TAURANGA", "TRENTHAM", "WHANGANUI", "RICCARTON SYNTHETIC", "TE RAPA", _

"OAMARU", "TAUPO", "WOODVILLE", "RIVERTON", "WINGATUI", "MATAMATA", "ASHBURTON", "CROMWELL", "OTAKI-MAORI", "TE AROHA", _

"WINGATUI", "CAMBRIDGE SYNTHETIC", "ELLERSLIE", "WHANGANUI", "REEFTON", "KUMARA", "RUAKAKA", "TAUHERENIKAU", "GREYMOUTH")

For i = 0 To UBound(TargetList)

Set range = ActiveDocument.range

With range.Find

.Text = TargetList(i)

.Format = True

.MatchCase = True

.MatchWholeWord = False

.MatchWildcards = False

.MatchSoundsLike = False

.MatchAllWordForms = False

Do While .Execute(Forward:=True) = True

range.Font.Bold = True

range.Font.Color = wdColorRed

range.HighlightColorIndex = wdTurquoise

Loop

End With

Next

End Sub

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2024-09-04T01:59:18+00:00

Hi Steve,

Is your requirement for the code you provided to only affect content with a font size of 14.5?

If so, please review the code below to see if it meets your needs:

Sub Track_Names2()

   Dim rng As Range

   Dim i As Long

   Dim TargetList As Variant

   TargetList = Array("AWAPUNI SYNTHETIC", "HAWERA", "ASCOT PARK", "HASTINGS", "PUKEKOHE", _

                     "NEW PLYMOUTH", "RICCARTON", "PHAR LAP", "WAVERLEY", "ROTORUA", _

                     "TAURANGA", "TRENTHAM", "WHANGANUI", "RICCARTON SYNTHETIC", "TE RAPA", _

                     "OAMARU", "TAUPO", "WOODVILLE", "RIVERTON", "WINGATUI", "MATAMATA", _

                     "ASHBURTON", "CROMWELL", "OTAKI-MAORI", "TE AROHA", "WINGATUI", _

                     "CAMBRIDGE SYNTHETIC", "ELLERSLIE", "WHANGANUI", "REEFTON", "KUMARA", _

                     "RUAKAKA", "TAUHERENIKAU", "GREYMOUTH")

   For i = 0 To UBound(TargetList)

       Set rng = ActiveDocument.Range

       With rng.Find

           .Text = TargetList(i)

           .Format = True

           .MatchCase = True

          .MatchWholeWord = False

          .MatchWildcards = False

          .MatchSoundsLike = False

          .MatchAllWordForms = False

           Do While .Execute(Forward:=True) = True

               If rng.Font.Size = 14.5 Then

                  rng.Font.Bold = True

                  rng.Font.Color = wdColorRed

                   rng.HighlightColorIndex = wdTurquoise

               End If

           Loop

       End With

   Next i

End Sub

Looking forward to your reply.

Best Regards,

Jonathan Z - MSFT | Microsoft Community Support Specialist

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2024-09-04T02:31:52+00:00

    Hello Jonathan Z

    Brilliant.

    Yes exactly what I required.

    I thank you very much.

    All the Best

    Steve

    Was this answer helpful?

    0 comments No comments