Salut ŕ toute la communauté
To find generic words in a word document and surround them with square brackets I use the following macro and it works:
Code:
Sub test()
Dim rngDoc As Word.Range
Dim sArray As Variant, tArray As Variant
Dim i As Long
sArray = Array("ABCD.0001/0002/0003")
tArray = Array("ABCD.0001", "ABCD.0002", "ABCD.0003")
Set rngDoc = ActiveDocument.Range
For i = 0 To UBound(sArray)
With rngDoc.Find
.ClearFormatting
.Text = sArray(i)
.Replacement.Text = "ABCD.0001 ABCD.0002 ABCD.0003"
.Execute Replace:=wdReplaceAll
End With
Next
For i = 0 To UBound(tArray)
With rngDoc.Find
.ClearFormatting
.Text = tArray(i)
.Replacement.Text = "[" & tArray(i) & "]"
.Execute Replace:=wdReplaceAll
End With
Next
End Sub
Is it possible to replace my tArray with an expression like "ABCD.[0-9]{4}" because my generic words can go from ABCD.0001 to ABCD.9999?
Thank you