-
Hi Jeeves,
Modified to suit
MD
[VBA] Option Explicit
Option Compare Text
Sub ChangeHeader()
Dim ToFind, ReplaceWith
Dim MyDS As String
Dim TF
Dim i As Integer
Application.ScreenUpdating = False
MyDS = ActiveDocument.MailMerge.DataSource.Name
ActiveDocument.MailMerge.EditDataSource
ToFind = Array("Add1", "Add2", "Add5")
ReplaceWith = Array("Add_1", "Add_2", "Add_5")
i = -1
For Each TF In ToFind
i = i + 1
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ToFind(i)
.Replacement.Text = ReplaceWith(i)
.Forward = True
.MatchWholeWord = True
End With
Selection.Find.Execute Replace:=wdReplaceOne
Next
Documents(MyDS).Close True
Application.ScreenUpdating = True
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules