Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 04-23-2020, 08:54 PM
gmayor's Avatar
gmayor gmayor is offline Format text based on Tag Windows 10 Format text based on Tag Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
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 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
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format cell and add a comment based on another tab Catluvr Excel Programming 8 08-03-2018 09:54 AM
Format text based on Tag Format Multiple Textboxes Based On the Contents of One Text Box dmcgettigan Word VBA 1 02-27-2017 08:50 PM
Format text based on Tag Format Text based on use elsewhere Rtowey Excel 1 07-21-2015 06:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft