View Single Post
 
Old 12-28-2021, 10:16 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,106
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following should work, however I suspect you may be converting to true title case in which case see VBA Code Examples (2)
Code:
Sub findMm()
Dim oRng As Range
Dim strfind() As Variant
Dim strreplace() As Variant
Dim i As Integer
    strfind = Array("A", "An", "The", "To", "With")
    strreplace = Array("a", "an", "the", "to", "with")
    For i = 0 To UBound(strfind)
        Set oRng = ActiveDocument.Range
        With oRng.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .Text = strfind(i)
            .Format = True
            .Forward = True
            .MatchWildcards = False
            .MatchCase = True
            .MatchWholeWord = True
            Do While .Execute
                If Not oRng.Start = oRng.Sentences(1).Start Then
                    oRng.Text = strreplace(i)
                End If
                oRng.Collapse 0
            Loop
        End With
    Next i
    Set oRng = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote