View Single Post
 
Old 04-23-2020, 08:54 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
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

If the styles exist in the document and the document is laid out as shown, try the following
Code:
Sub TextChanger()
Dim i As Long
Const StrFind As String = "ALB,TRI,QIU,FSF"
    On Error Resume Next
    Application.ScreenUpdating = False
    For i = 0 To UBound(Split(StrFind, ","))
        With ActiveDocument.Range.Find
            .ClearFormatting
            .Replacement.ClearFormatting
            .Forward = True
            .Format = True
            .Wrap = wdFindContinue
            .MatchWildcards = True
            .Text = "\@" & Split(StrFind, ",")(i) & " = (*^13)"
            .Replacement.Style = Split(StrFind, ",")(i)
            .Replacement.Text = "\1"
            .Execute Replace:=wdReplaceAll
        End With
    Next i
    Application.ScreenUpdating = True
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