![]() |
|
#1
|
|||
|
|||
|
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
Thank you |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Help with WildCards Find & Replace either or nothing...
|
Cendrinne | Word VBA | 9 | 11-14-2020 08:25 AM |
| Advanced Find and Replace with Wildcards help needed | Amapola188 | Word | 3 | 07-23-2019 10:54 PM |
Find and replace text with wildcards
|
arunchandar9 | Word VBA | 15 | 06-30-2019 01:06 AM |
| Using wildcards how do I Find and Add to, not replace | Stargehzer | Word | 3 | 01-25-2016 09:14 PM |
| Find & Replace: Wildcards (except this pattern) | tinfanide | Word | 6 | 01-26-2014 06:39 AM |