View Single Post
 
Old 12-14-2023, 01:32 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,138
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

How about
Code:
Sub AddFooterWithPageNumber()
    Dim oSection As section
    Dim oFooter As HeaderFooter
    Dim oRng As Range
    
    ' Loop through each section in the document
    For Each oSection In ActiveDocument.Sections
        oSection.PageSetup.FooterDistance = CentimetersToPoints(1)
        For Each oFooter In oSection.Footers
            If oFooter.Exists Then
                Set oRng = oFooter.Range
                oRng.Fields.Add oRng, wdFieldPage, , False
                oRng.ParagraphFormat.Alignment = wdAlignParagraphRight
                ' Set font properties
                With oRng.Font
                    .Name = "Times New Roman"
                    .Size = 14
                End With
            End If
        Next oFooter
    Next oSection
lbl_Exit:
    Set oSection = Nothing
    Set oFooter = Nothing
    Set oRng = Nothing
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