Update fields in footers

S

Sammy

I have this macro which updates the fields in the footer. I doubt it is the
best way to make this happen...also it doesn't work in all sections. Any
advice would be appreciated! Thanks



If Documents.Count = 0 Then Exit Sub

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 = wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
Selection.WholeStory
Selection.Fields.Update
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
 
D

Doug Robbins - Word MVP

Sometimes, just using

With ActiveDocument
.PrintPreview
.ClosePrintPreview
End With

is an easy way of doing it.

Or you may use

Dim i As Long
With ActiveDocument
For i = 1 To .Sections.Count
With .Sections(i)
.Headers(wdHeaderFooterFirstPage).Range.Fields.Update
.Headers(wdHeaderFooterPrimary).Range.Fields.Update
.Footers(wdHeaderFooterFirstPage).Range.Fields.Update
.Footers(wdHeaderFooterPrimary).Range.Fields.Update
End With
Next
End With



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
S

Sammy

Wonderful! Thanks

Doug Robbins - Word MVP said:
Sometimes, just using

With ActiveDocument
.PrintPreview
.ClosePrintPreview
End With

is an easy way of doing it.

Or you may use

Dim i As Long
With ActiveDocument
For i = 1 To .Sections.Count
With .Sections(i)
.Headers(wdHeaderFooterFirstPage).Range.Fields.Update
.Headers(wdHeaderFooterPrimary).Range.Fields.Update
.Footers(wdHeaderFooterFirstPage).Range.Fields.Update
.Footers(wdHeaderFooterPrimary).Range.Fields.Update
End With
Next
End With



--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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