![]() |
|
#1
|
|||
|
|||
|
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
Thanks |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Updating page number in table cells in footer in each page
|
nyconfidential | Word VBA | 1 | 08-13-2022 03:37 PM |
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 |
Footer for page numbers recently started showing a colored field when adding page numbers
|
thefonebug | Word | 12 | 10-24-2016 05:18 AM |
Total Page number incorrect in the first page footer
|
mmathisekar | Word | 11 | 06-16-2016 06:00 AM |