This VBA macro can be used to set up a standard footer in your Word documents which includes the full path and filename for the report as well as the current page out of total pages.
Now each time I create a report, I have a simple macro to run which creates a standard footer which shows others where to find the electronic version of my printed reports.
Here is the code
Sub InsertFooter()
' InsertFooter Macro
' Insert a File Footer with filename and page numbers
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
'Set the footer
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.Font.Size = 9
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="FILENAME \p ", PreserveFormatting:=True
Selection.TypeText Text:=vbTab
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="PAGE ", PreserveFormatting:=True
Selection.TypeText Text:=" of "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="NUMPAGES ", PreserveFormatting:=True
End Sub

No comments:
Post a Comment