![]() |
#1
|
|||
|
|||
![]() Hello, ![]() I would be grateful for help on my code below. I just want to find the first instance of each words in the array and then do a replace task on it. Example find the first instance of Air Boat then do a replacement on that only. Ignore all other Air Boats Code:
Sub Insert_After_First_Instance() Dim oRng As Word.Range Dim arrWords Dim i As Long arrWords = Array("Air Boat", "Power Boat", "Ferry") arrInsertAfter = Array("AB123", "PB456", "F123") For i = 0 To UBound(arrWords) Set oRng = ActiveDocument.Range With oRng.Find .ClearFormatting .Replacement.ClearFormatting .Text = arrWords(i) .MatchWholeWord = True .Replacement.Text = arrWords(i) & arrInsertAfter(i) .Execute Replace:=wdReplaceAll End With Next End Sub dan |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
roderh | Excel Programming | 2 | 09-06-2015 08:54 PM |
![]() |
paulkaye | Word | 3 | 12-22-2014 02:52 AM |
![]() |
psychologist | Word VBA | 3 | 11-22-2014 11:40 AM |
Find instance of a word in a specific style and change its color | hwg | Word VBA | 7 | 02-20-2014 10:59 PM |
Highlight text and find next instance | DrDOS | Word | 0 | 11-15-2010 04:02 PM |