Filename and path footer on every page of every section of document in Word 2000

I need a filename and path footer on every page of every section in documents in Word 2000.  I've got the code I need from Rajesh (thanks!) here:

http://www.experts-exchange.com/Applications/MS_Office/Word/Q_20794791.html#9736024

But I can't figure out if there's a different first page footer how to make it work.

Here's what I have so far:

Sub FooterEveryPage()
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.HomeKey Unit:=wdStory
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
sCount = ActiveDocument.Sections.Count
For sec = 1 To sCount
With ActiveDocument.Sections(sec)
If ActiveDocument.Sections(sec).Application.Selection. _
HeaderFooter.LinkToPrevious = False Then
    InsertFooter
End If
End With
If sec < sCount Then ActiveWindow.ActivePane.View.NextHeaderFooter
Next sec
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

Sub InsertFooter()
    Selection.EndKey Unit:=wdStory
    Selection.TypeParagraph
    Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
    Selection.Font.Size = 8
    NormalTemplate.AutoTextEntries("Filename and path").Insert Where:= _
        Selection.Range
    Selection.TypeParagraph
    Selection.InsertDateTime DateTimeFormat:="M/d/yyyy h:mm am/pm", _
        InsertAsField:=True, DateLanguage:=wdEnglishUS, CalendarType:= _
        wdCalendarWestern, InsertAsFullWidth:=False
End Sub

Many thanks!
LVL 37
Joanne M. OrzechManager, Document Services CenterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tommy KinardCommented:
Hi JOrzech,

I changed the above code to pick up all of the footers. I tested on a blank doc with a different first page header, 3 pages. If there is more that you need let me know.

Sub FooterEveryPage()
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
        ActivePane.View.Type = wdOutlineView Then
            ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    Selection.HomeKey Unit:=wdStory
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
' start changes ******
    While Err.Number = 0                                '< added this for an exit key
        sCount = ActiveDocument.Sections.Count
        For sec = 1 To sCount                            '< in my testing this remains 1 maybe yours doesn't I used a blank doc
            With ActiveDocument.Sections
                If ActiveDocument.Sections.Application.Selection. _
                HeaderFooter.LinkToPrevious = False Then
                    InsertFooter
                End If
            End With
        Next sec
        On Error Resume Next                  '< resume next on error cause it throws an error when no more different footers
        ActiveWindow.ActivePane.View.NextHeaderFooter
    Wend
    Err.Clear             '< there is an error so exit clear error get through
    On Error GoTo 0
' end changes ****** I commented out the trouble are and left alone - backup place to start
    'sCount = ActiveDocument.Sections.Count
    'For sec = 1 To sCount
    '    With ActiveDocument.Sections(sec)
    '        If ActiveDocument.Sections(sec).Application.Selection. _
    '        HeaderFooter.LinkToPrevious = False Then
    '            InsertFooter
    '        End If
    '    End With
    '    If sec < sCount Then ActiveWindow.ActivePane.View.NextHeaderFooter
    'Next sec
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

Sub InsertFooter()
    Selection.EndKey Unit:=wdStory
    Selection.TypeParagraph
    Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
    Selection.Font.Size = 8
    NormalTemplate.AutoTextEntries("Filename and path").Insert Where:= _
        Selection.Range
    Selection.TypeParagraph
    Selection.InsertDateTime DateTimeFormat:="M/d/yyyy h:mm am/pm", _
        InsertAsField:=True, DateLanguage:=wdEnglishUS, CalendarType:= _
        wdCalendarWestern, InsertAsFullWidth:=False
End Sub

HTH
dragontooth


0
Joanne M. OrzechManager, Document Services CenterAuthor Commented:
Awesome Dragontooth!  It works great except it puts four footers on each page....
0
Joanne M. OrzechManager, Document Services CenterAuthor Commented:
If it's any clue - my document has four sections.  If I add another section, it adds five footers....clear this up and I'll be a very happy camper :)

Thanks so much!
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tommy KinardCommented:
Hi JOrzech,

I thought that would happen - I test with one section and LOL here we go.
Anyway I don't think the quantity of sections has anything to do with the footers so lets take it out and try that one. The folowing is the revised code without the comment and etc. Indented because it was easier for me to read.


 Sub FooterEveryPage()
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or _
        ActiveWindow.ActivePane.View.Type = wdOutlineView Then
            ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    Selection.HomeKey Unit:=wdStory
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    While Err.Number = 0
        With ActiveDocument.Sections
            If .Application.Selection.HeaderFooter.LinkToPrevious = False Then  '< removed the ActiveDocument.Sections - you used with already no need to repeat
                InsertFooter
            End If
        End With
        On Error Resume Next
        ActiveWindow.ActivePane.View.NextHeaderFooter
    Wend
    Err.Clear
    On Error GoTo 0
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

HTH
dragontooth

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Joanne M. OrzechManager, Document Services CenterAuthor Commented:
You are awesome!!!!  Excellent work Dragontooth.  Increased points for ya ;)

Thanks again.

Joanne

0
Tommy KinardCommented:
Thanks for the Points and the Grade!!

dragontooth

0
Eric FletcherCommented:
Hmm... maybe I'm missing something here but why not just use the built-in filename field with the \p option in the page footers?

I use {FILENAME \p} all the time in Word XP. (You can get it from the Insert Field... dialog or type in "filename \p" (no quotes), select it and press Ctrl-F9 to change it to a field code.)

Eric
0
Joanne M. OrzechManager, Document Services CenterAuthor Commented:
But page footers change from section to section
0
Tommy KinardCommented:
@JOrzech, page footers change on each page that is why the rewrite occured <If I add another section, it adds five footers> There is also a different first page footer, odd/even page footer and last but not least just a plain old footer on each page either not like the others/or like the others.

@EricFletcher, Word 200 does not allow {FILENAME \p} to be type as you suggested (what happens is the {FILENAME \p} stays that way). The insert field is allowed and it works real good. Word 2000 is not as flexible as Word XP I guess.

dragontooth

0
Eric FletcherCommented:
Dragontooth: It should work. I also have Word 97 on an old laptop and it works fine there. If you see the field braces after you pressed Ctrl-F9, the definition took -- but you probably didn't toggle the view with Alt-F9 to see the results. (This has been an annoyance in Word for ages: the excuse I was given is that people need to see that they've added a field code; otherwise they might get confused if something else just suddenly appeared.)

As with many fields, you may need to cause this field to be "recalculated" by pressing F9 or switching out of page view and back. Also, note that if you haven't saved the file yet, the path will not show.

Eric
0
Tommy KinardCommented:
Ah the Alt-F9, didn't know that Thanks. I would also like to thank you for your comments the more I learn the more I find I don't know!

Follow the link below in appreciation of the time, tip, and your very productive comments.

http://www.experts-exchange.com/Applications/MS_Office/Word/Q_20827584.html

dragontooth

0
Joanne M. OrzechManager, Document Services CenterAuthor Commented:
You guys are awesome...but I work with Word 2000 at work.... :(

I know about he alt f9 and all that other.... mebbe I'm the one missing something... tell me, is it true?
0
Tommy KinardCommented:
IMHO no. I didn't know about the alt-F9, but not knowing exactly what is going on, I will not tell someone to update their fields, the reason is some fields are filled though code, Alt-F9 would reset these fields and the information would be gone. Another thing is you may be printing out the doc before saving in which case the field would not be updated until save if I understand correctly. So from an end user's standpoint the {FILENAME \p} would work just fine/the best, IMHO from a coders viewpoint there are other options that would be best depending on the requirements. ex. The filename in the footer is where the original is stored but the current one is actually someplace else.

dragontooth

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.