View Single Post
 
Old 02-09-2023, 07:15 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

You should change the range then add fields e.g.
Code:
Dim oRng As Range
Set oRng = Selection.Range
With oRng
    .Fields.Add Range:=oRng, Type:=wdFieldIf, Text:="{PAGE} = {NUMPAGES} ""last page""", PreserveFormatting:=False
    .Collapse 1
    .MoveEndUntil "}"
    .End = .End + 1
    .MoveStartUntil "{"
    .Text = ""
    .Fields.Add Range:=oRng, Type:=wdFieldPage, PreserveFormatting:=False
    .Collapse 0
    .MoveEndUntil "}"
    .End = .End + 1
    .MoveStartUntil "{"
    .Text = ""
    .Fields.Add Range:=oRng, Type:=wdFieldNumPages, PreserveFormatting:=False
    .Fields.Update
End With
__________________
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