Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jun 2004
    Location
    Oxford, Oxfordshire, United Kingdom
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find/Replace Macro for Headers (2002 SR3)

    I'm trying to create a macro that will do some finding and replacing in Headers.
    If I just do the job manually it works--I do a global find and replace for 'Month' and put in 'January', and it works nicel, doing the replacement in all three headers (first page, odd page, even page). . If I record a macro as I do it, I get what we have below. But as a macro it doesn't work--I run it, and nothing happens. (The full macro will be a bit more complicated than this--but the rub is coming here.)
    Can anyone see why and make any suggestions? This is a routine my office needs to automate, because we keep on forgetting to do it manually!

    best wishes

    Philip

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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find/Replace Macro for Headers (2002 SR3)

    Your code will only search and replace in the body of the document. See Using a macro to replace text where ever it appears in a document including Headers, Footers, Textboxes, etc. on the Word MVP site.

  3. #3
    3 Star Lounger
    Join Date
    Jun 2004
    Location
    Oxford, Oxfordshire, United Kingdom
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find/Replace Macro for Headers (2002 SR3)

    Thanks! Microsoft do make things complicated ... but I've got the automated routine running now. I'm so grateful

    Philip

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •