VBA for Headings
I want to input the clients name and then have if fill in the template where I have put the (CLIENT NAME) place holder. When I delete the headers portion of the code it works but when I run it with it I get a " The requested member of the collection does not exist" Error. Any suggestions on how to fix?
strSubName = InputBox("Enter Client Name")
OldWord = "(CLIENT NAME)"
NewWord = strSubName
With ActiveDocument.Content.Find
.Forward = True
.Wrap = wdFindStop
.Execute FindText:=OldWord, ReplaceWith:=NewWord, Replace:=wdReplaceAll, MatchCase:=True
End With
With ActiveDocument.Sections(i).Headers(1).Range.Find
.Text = "(CLIENT NAME)"
.Replacement.Text = strSubName
.Wrap = wdFindContinue
.Execute Replace:=wdReplaceAll
End With
|