Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 05-04-2016, 03:52 AM
gmayor's Avatar
gmayor gmayor is offline Inserting new footer into existing documents Windows 10 Inserting new footer into existing documents Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Inserting new footer into existing documents edit date in footer of existing slides eNGiNe PowerPoint 6 05-27-2015 05:39 AM
Inserting new footer into existing documents 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

Other Forums: Access Forums

All times are GMT -7. The time now is 05:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft