M
Mary
Hi
I have a footer in my word document which display the
document title - when I change the document title it does
not update my footer automatically. I don't really want
my users to have to open the footer and use F9
I added this procedure which was working fine but I guess
I have accidentally changed something as it no longer
works but shows me an error (No errors if I open the
template but the following error msg if I open any docs
based on the template) error msg is:- run time error 91 -
object variable or with not set
Please see my code below
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.HeaderFooter.LinkToPrevious = False
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
I have a footer in my word document which display the
document title - when I change the document title it does
not update my footer automatically. I don't really want
my users to have to open the footer and use F9
I added this procedure which was working fine but I guess
I have accidentally changed something as it no longer
works but shows me an error (No errors if I open the
template but the following error msg if I open any docs
based on the template) error msg is:- run time error 91 -
object variable or with not set
Please see my code below
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.HeaderFooter.LinkToPrevious = False
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