I'm building my footers via code. I'm having an issue properly formatting the page counts in my Word footer when adding the fields via VBA. When the code runs the formatting always ends up as XXof XX (1of 20) instead of XX of XX (1 of 20). I have tried the following but the numbers always show the page number without a space before the word "of".
With rng
.Text = "NUMPAGES "
Set oFooterRng1 = rng.Words(1)
.Fields.Add Range:=oFooterRng1, Type:=wdFieldEmpty, Text:="NUMPAGES \* Arabic ", PreserveFormatting:=True
End With
rng.Collapse wdCollapseStart
rng.Text = " of "
rng.Collapse wdCollapseStart
With rng
.Text = "PAGE "
Set oFooterRng1 = rng.Words(1)
.Fields.Add Range:=oFooterRng1, Type:=wdFieldEmpty, Text:="PAGE \* Arabic ", PreserveFormatting:=True
End With
or this
With rng
.Text = "PAGE of NUMPAGES "
Set oFooterRng1 = rng.Words(1)
Set oFooterRng2 = rng.Words(3)
.Fields.Add Range:=oFooterRng1, Type:=wdFieldEmpty, Text:="PAGE \* Arabic ", PreserveFormatting:=True
.Fields.Add Range:=oFooterRng2, Type:=wdFieldEmpty, Text:="NUMPAGES \* Arabic ", PreserveFormatting:=True
End With
rng.Text = Chr(32) & "of "
– Samuel Everson