Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-27-2021, 11:28 PM
LQuinn LQuinn is offline find/replace wildcard expression help Windows 10 find/replace wildcard expression help Office 2019
Novice
find/replace wildcard expression help
 
Join Date: Jan 2021
Location: Western Australia
Posts: 20
LQuinn is on a distinguished road
Default find/replace wildcard expression help

Hi all, new to wildcards/expressions and looking for some help please



Where I work we have a document control system that generates unique document IDs as follows:
  • TA8X.0100185.S14.03EN
  • TA8X.0100185.D07.24EN
  • TA8X.0100184.S14.00EN
  • TA8X.0100185.D07.01EN
  • TA8X.0100185.D07.06EN
  • 109E.0101548.D03.00EN
  • 109E.0101549.D03.00EN
  • 109E.0101552.D03.00EN
  • 90000199.L03.EN
  • SWMS-BE-ETCS-GEN-58
  • SWMS-BE-ETCS-GEN-61
  • SWMS-BE-ETCS-GEN-63
  • TA8X.0100185.D07.04EN
  • TA8X.0100184.A07.00EN
  • B63E.0100030.D01.00EN
  • B63E.0100029.D02.00EN
  • B63E.0100029.D02.00EN
  • TA8X.0100185.D07EN
  • TA8X.0100185.D07.02EN REV 01.00
  • TA8X.0100185.D07.00EN REV 01.00
  • TA8X.0100185.D07.12EN REV 00.00
  • TA8X.0100XXX.D07.02EN REV 00.00
  • P12E.0100086.D02.00EN
  • B60A.0100655.D02.00EN
  • B60A.0100650.D02.00EN
  • B60A.0100653.D02.EN
  • B60A.0100656.D02.00EN
  • B60A.0100657.D02.00EN
  • B63E.0100040D01.00EN
  • B60A.0100667.D02.00EN
  • TA8X.0100185.L03.00EN.
  • TA8X.0100185.D07.
  • B631.0100007.D02.00EN.
  • B631.0100009.D02.00EN.
  • TA8X.0100185.L03.00EN
  • TA8X.0100185.D07.17EN.

I'm trying to find and format based on wildcards in find/replace, but Word is generating a 'pattern match too complex' error message if I add this for 'SWMS'
"<([A-Z]{4}[-])([A-Z]{2}[-])([A-Z]{4}[-])([A-Z]{3}[-])([0-9]{2})>"

hoping this is enough detail for someone to point me in the right direction please!

Code:
Private Sub Tools_Text_Format_TeamCenter_Document_Numbers()
'
' find teamcenter document numbers and format them
'
' https://regex101.com/
'
    Dim arrFindReplaceExpressions()
    Dim varCounter As Variant

    arrFindReplaceExpressions = Array("<([0-9A-Z]{4}[.])([0-9A-Z]{7}[.])([0-9A-Z]{3}[.])([0-9A-Z.]{4})>", _
                                      "<([0-9A-Z]{4}[.])([0-9A-Z]{7}[.])([0-9A-Z]{3}[.])([0-9A-Z.]{2})>", _
                                      "<([0-9]{8}[.])([0-9A-Z]{3}[.])([A-Z]{2})>")
    
    For Each varCounter In arrFindReplaceExpressions
        Selection.Find.ClearFormatting
        Selection.Find.Replacement.ClearFormatting
        With Selection.Find
            '.Replacement.Text = ""
            .Text = varCounter
            .Replacement.Font.Bold = True
            .Forward = True
            .Wrap = wdFindContinue
            .Format = True
            .MatchCase = False
            .MatchWholeWord = False
            .MatchAllWordForms = False
            .MatchSoundsLike = False
            .MatchWildcards = True ' needed for special characters, otherwise they're treated as ordinary text
            .Execute Replace:=wdReplaceAll
        End With
    Next varCounter
    
    Set varCounter = Nothing
    Erase arrFindReplaceExpressions
    
    Debug.Print "Finished!"
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help With Find and Replace Wildcard rsrasc Word VBA 9 10-13-2015 02:37 PM
find/replace wildcard expression help Wildcard Find and Replace anomaly BruceM Word 3 07-10-2015 04:33 AM
find/replace wildcard expression help New Find/Replace Wildcard Needed rsrasc Word VBA 2 11-11-2014 09:46 AM
find/replace wildcard expression help Wildcard Find and Replace Ulodesk Word 1 06-23-2014 10:26 AM
find/replace wildcard expression help Need help using WildCard Find & Replace Cayce Word 1 06-09-2014 04:17 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:26 PM.


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