Group: microsoft.public.word.vba.general
From: =?Utf-8?B?U2FtbXk=?=
Date: Thursday, March 13, 2008 4:04 PM
Subject: Replace code in header

Hi,

The following macro works in the body of the document but not in the Header
or Footer. What am I doing wrong?? Thanks for your help

Dim strCodes As String
Dim iFld As Integer
Dim strFind As String
Dim strRepl As String
Dim pRange As Word.Range


For Each pRange In ActiveDocument.StoryRanges
Do Until pRange Is Nothing
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldDate Then
.Code.Text = Replace(UCase(.Code.Text), _
"DATE", "CREATEDATE")
End If
End With
Next iFld
Set pRange = pRange.NextStoryRange
Loop
Next