![]() |
|
#2
|
||||
|
||||
|
The following will remove the Primary Header content and add the footer to the Primary Footer. The first page header and footer are unaffected.
Note the macro addresses only the first section of the document. Letters don't usually have multiple sections, but if yours do the additional sections need to be addressed. Code:
Option Explicit
Sub ChangeHeaderFooter()
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter
Dim strName As String
Dim orng As Range
strName = InputBox("Enter addressee's name")
ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True
Set oHeader = ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
oHeader.Range.Text = ""
Set oFooter = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary)
Set orng = oFooter.Range
orng.ParagraphFormat.TabStops.ClearAll
orng.ParagraphFormat.TabStops.Add _
Position:=CentimetersToPoints(16.5), _
Alignment:=wdAlignTabRight, _
Leader:=wdTabLeaderSpaces
orng.Text = strName & " | " & Format(Date, "d MMMM yyyy") & vbTab & "Page "
orng.Collapse 0
orng.Fields.Add Range:=orng, Type:=wdFieldPage, PreserveFormatting:=False
lbl_Exit:
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
edit date in footer of existing slides
|
eNGiNe | PowerPoint | 6 | 05-27-2015 05:39 AM |
Inserting Table of Figures Insists on Overwriting Existing
|
sleake | Word | 8 | 09-15-2013 02:42 PM |
| How to insert full documents into existing word document | Laraak | Word | 1 | 03-07-2013 11:59 PM |
| Inserting section between existing sections | GoneBirding | Word | 0 | 10-18-2012 03:01 PM |
| Assigning templates to existing documents. Update Styles Enmasse. | bannerdog | Word | 1 | 02-28-2012 03:53 PM |