View Single Post
 
Old 07-22-2024, 04:22 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,636
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Change this section of your original code:


Code:
For i = LBound(myarray) To UBound(myarray)
    Selection.HomeKey wdStory
    Selection.Find.ClearFormatting
    With Selection.Find
    Do While .Execute(FindText:=myarray(i, 1), Forward:=True, _
    MatchWildcards:=True, Wrap:=wdFindStop, MatchCase:=False) = True
    Set rng = Selection.Range
    Selection.Collapse wdCollapseEnd
    rng.Font.Italic = True
    rng.Font.Bold = True
    rng.Font.Color = RGB(200,187,0)
    rng.Font.Name ="Times New Roman"
    rng.Case=  wdTitleSentence 'wdUpperCase works; this doesn't; something else I could put here?
     Loop
Next i

to:


Code:
Dim oRng As Range Dim strFind As String
   For i = LBound(myarray) To UBound(myarray)
    strFind = myarray(i)
    Set oRng = ActiveDocument.Range
    With oRng.Find
      .Text = strFind
      .Forward = True
      .Wrap = wdFindStop
      .MatchCase = False
      While .Execute
         oRng.Font.Italic = True
         oRng.Font.Bold = True
         oRng.Font.Color = RGB(200, 187, 0)
         oRng.Font.Name = "Times New Roman"
         oRng.Case = wdLowerCase 
         oRng.Words(1).Characters(1).Case = wdUpperCase
         oRng.Collapse wdCollapseEnd
      Wend
   End With
   Next i

or the other variation I suggested.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote