K
Kerri
Hi,
I'm in Word 2003, I am trying to insert text in to all sections
including first page header. I don't want to just remove what is
already there. I need to see if a doc number appears if so then
delete just that. I have the guts figured out. My problem it's not
moving to the next header if it exists and it's inserting my text
three times in the first page. I got this code from another help
file. The code below has been modified and is my trimed down version.
Any help would be greatly appreciated.
Sub HDFtrSections()
Dim i As Long
Dim ftr As HeaderFooter
Dim sec As Section
Dim rng As Range
WordBasic.ViewFooter 'I know I should update this but it still
works.
With ActiveDocument
For i = 1 To .Sections.Count
'loop through each section in doc
For Each ftr In .Sections(i).Footers
'Don't remove existing text
'Don't add a hard return if the range is ""
'If bkmk exists then delete text
'if Find.found = True then delete text
'Create new bookmark and insert doc name.
Selection.Range.Text = "blah blah blah"
'It stays in the same footer repeating the steps.
'The first footer is First Page footer.
'Or it inserts the text three times. For the number of
sections.
Next ftr
Next i
End With
End Sub
Thank you for your time.
Kerri
I'm in Word 2003, I am trying to insert text in to all sections
including first page header. I don't want to just remove what is
already there. I need to see if a doc number appears if so then
delete just that. I have the guts figured out. My problem it's not
moving to the next header if it exists and it's inserting my text
three times in the first page. I got this code from another help
file. The code below has been modified and is my trimed down version.
Any help would be greatly appreciated.
Sub HDFtrSections()
Dim i As Long
Dim ftr As HeaderFooter
Dim sec As Section
Dim rng As Range
WordBasic.ViewFooter 'I know I should update this but it still
works.
With ActiveDocument
For i = 1 To .Sections.Count
'loop through each section in doc
For Each ftr In .Sections(i).Footers
'Don't remove existing text
'Don't add a hard return if the range is ""
'If bkmk exists then delete text
'if Find.found = True then delete text
'Create new bookmark and insert doc name.
Selection.Range.Text = "blah blah blah"
'It stays in the same footer repeating the steps.
'The first footer is First Page footer.
'Or it inserts the text three times. For the number of
sections.
Next ftr
Next i
End With
End Sub
Thank you for your time.
Kerri