bstephens
11-29-2009, 02:56 AM
I'm trying to write a macro that will update the fields in the last SECTION of documents based on a template on a user save event.
I've been parsing through code trying to figure this out and I got as far as the following code which is supposed to update the FOOTER on a save event.
Private Sub oApp_DocumentBeforeSave(ByVal Doc As Document, _
SaveAsUI As Boolean, Cancel As Boolean)
Sub UpdateFooter()
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 = wdSeekCurrentPageFooter
Selection.WholeStory
Selection.Fields.Update
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
This code doesn't seem to work.
Does anyone have an idea how to write a macro where word updates the fields in the last SECTION of the document only before a save event?
I am in Word 2007.
Thanks for any ideas.
Brian
I've been parsing through code trying to figure this out and I got as far as the following code which is supposed to update the FOOTER on a save event.
Private Sub oApp_DocumentBeforeSave(ByVal Doc As Document, _
SaveAsUI As Boolean, Cancel As Boolean)
Sub UpdateFooter()
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 = wdSeekCurrentPageFooter
Selection.WholeStory
Selection.Fields.Update
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub
This code doesn't seem to work.
Does anyone have an idea how to write a macro where word updates the fields in the last SECTION of the document only before a save event?
I am in Word 2007.
Thanks for any ideas.
Brian