Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-13-2023, 01:48 PM
laith93 laith93 is offline Adding footer page number with custom style Windows 10 Adding footer page number with custom style Office 2019
Competent Performer
Adding footer page number with custom style
 
Join Date: Jul 2021
Posts: 117
laith93 is on a distinguished road
Default Adding footer page number with custom style

Hi,
I want a macro to add a footer with the page number on the right, the distance from the bottom (1cm), the style of footer text (Times new roman, 14pt), I tried and used this macro, but didn't fulfill my requirement

Code:
Sub AddFooterWithPageNumber()
    Dim section As section
    Dim footer As range
    
    ' Loop through each section in the document
    For Each section In ActiveDocument.Sections
        Set footer = section.Footers(wdHeaderFooterPrimary).range
        
        ' Clear existing content in the footer
        footer.Text = ""
        
        ' Set font properties
        With footer.Font
            .Name = "Times New Roman"
            .Size = 14
        End With


        Dim positionFromBottom As Double
        positionFromBottom = CentimetersToPoints(1)
        
        footer.Fields.Add range:=footer, Type:=wdFieldPage
        
        ' footer.Text = " - "  ' Uncomment this line if you want to add a separator
       
        
'         Update the footer
'        footer.Updates
    Next section
End Sub
Any help, suggestions
Thanks
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding footer page number with custom style Updating page number in table cells in footer in each page nyconfidential Word VBA 1 08-13-2022 03:37 PM
Adding footer page number with custom style Page number shows up as { PAGE } instead of number and question about area allowed for footer dw85745 Word 3 01-16-2022 03:19 PM
Don't want page number or date in footer on first page, do want graphic in header. dianahbr Word 2 02-23-2018 09:25 AM
Adding footer page number with custom style Footer for page numbers recently started showing a colored field when adding page numbers thefonebug Word 12 10-24-2016 05:18 AM
Adding footer page number with custom style Total Page number incorrect in the first page footer mmathisekar Word 11 06-16-2016 06:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:21 PM.


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