Macro To Replace Text In Header

W

WCyrek

Hi not sure why my macro doesnt replace stuff in the
header

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "<Subject>"
.Replacement.Text = NameTextBox.Text
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll


PLZ HELP
 
W

WCyrek

With ActiveDocument.Sections(1)
.Headers(wdHeaderFooterPrimary).Range.Text
= "Confidential Due Diligence Report - " &
NameTextBox.Text
End With

Yey :/
 
D

Doug Robbins

See the article "Using a macro to replace text where ever it appears in a
document including Headers, Footers, Textboxes, etc." at:

http://word.mvps.org/FAQs/Customization/ReplaceAnywhere.htm


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top