Headers & Footers

M

Mary

I have inserted the Title field into the footer of my
document, however, if I change the document title the
footer does not automatically update.

I added this procedure to the open event of the document,
it was working fine but now it is showing an error.

Run time error 91 - object variable or with not set

Can anyone help?? Thanks for your time.
__________

Private Sub Document_Open()
'move to page 2 of the document
Selection.HomeKey unit:=wdStory
Selection.GoTo What:=wdGoToPage,
Which:=wdGoToNext, Count:=1
'update fields in the header
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = True
Selection.WholeStory
Selection.Fields.Update
'update fields in the footer
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter
Selection.WholeStory
Selection.Fields.Update
'Close Header Footer view & return to the top of the doc
ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
Selection.HomeKey unit:=wdStory
End Sub
 
C

Cindy M -WordMVP-

Hi Mary,

Working with "Selection" when trying to manipulate headers
and footers is unreliable. Better is to address the exact
range. Since you move to page 2, apparently your document
has more than one header and footer? Is this a case of
"Different first page" or do you have a section break in
there?
I have inserted the Title field into the footer of my
document, however, if I change the document title the
footer does not automatically update.

I added this procedure to the open event of the document,
it was working fine but now it is showing an error.

Run time error 91 - object variable or with not set

Can anyone help?? Thanks for your time.
__________

Private Sub Document_Open()
'move to page 2 of the document
Selection.HomeKey unit:=wdStory
Selection.GoTo What:=wdGoToPage,
Which:=wdGoToNext, Count:=1
'update fields in the header
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
Selection.HeaderFooter.LinkToPrevious = True
Selection.WholeStory
Selection.Fields.Update
'update fields in the footer
ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageFooter
Selection.WholeStory
Selection.Fields.Update
'Close Header Footer view & return to the top of the doc
ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
Selection.HomeKey unit:=wdStory
End Sub

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun
8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:)
 

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