View Single Post
 
Old 02-09-2023, 07:29 AM
Ddadoo57 Ddadoo57 is offline Windows 11 Office 2021
Advanced Beginner
 
Join Date: Feb 2023
Posts: 90
Ddadoo57 is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
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


thanks i will try that too!

Cordially
Reply With Quote