![]() |
|
#1
|
|||
|
|||
|
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:
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
|
|
|
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 |
Wildcard Find and Replace anomaly
|
BruceM | Word | 3 | 07-10-2015 04:33 AM |
New Find/Replace Wildcard Needed
|
rsrasc | Word VBA | 2 | 11-11-2014 09:46 AM |
Wildcard Find and Replace
|
Ulodesk | Word | 1 | 06-23-2014 10:26 AM |
Need help using WildCard Find & Replace
|
Cayce | Word | 1 | 06-09-2014 04:17 PM |