Footer Macro

N

Nancu

Thanks for looking at this. I need a macro that will go
into each footer in each section of my document (first
page footers included) and type some text. Here's my
attempt:

Sub testFooters()
If Documents.Count = 0 Then Exit Sub

Dim i As Integer
For i = 1 To ActiveDocument.Sections.Count

With ActiveDocument.Sections(i)

ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter

Selection.TypeText
Text:="C:\nrport\Admin\AGarber\xx9323_1.doc"

ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument

End With
Next i

End Sub

It simply repeats the text many times in the same footer.
Can you help me with the code? Thanks a lot
 
J

Jezebel

First, if all you want to do is put the filename into the footer, simpler is
to use a FileName field -- then you have no work to do at all.

However, if you really want to iterate all the footers of a document --

Dim pFooter as Word.Range
Dim pIndex as long
For pIndex = 1 to 3
Set pFooter = ActiveDocument.StoryRanges(Choose(pIndex, _
wdPrimaryFooterStory, _
wdFirstPageFooterStory, _
wdEvenPagesFooterStory))

Do until pFooter is nothing
pFooter.InsertAfter "mytext" 'or whatever you want to do
set pFooter = pFooter.NextStoryRange
Loop

Next
 

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