A
avkokin
Hello.
I need to insert field into footer. Field of number pages in active
document and minus 1. That is field: {={numpages}-1}
I try it insert with next code:
sub insPN ()
Dim myRange As Range
Set myRange =
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
Selection.Fields.Add Range:=myRange, Type:=wdFieldEmpty, Text:="=",
PreserveFormatting:=False
Selection.Fields.Add Range:=myRange, Type:=wdFieldEmpty,
Text:="numpages", PreserveFormatting:=False
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="-1"
Selection.Fields.Update
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
end sub
I get the mistake.
Wherein my mistake?
Thank you very much for help.
I need to insert field into footer. Field of number pages in active
document and minus 1. That is field: {={numpages}-1}
I try it insert with next code:
sub insPN ()
Dim myRange As Range
Set myRange =
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range
Selection.Fields.Add Range:=myRange, Type:=wdFieldEmpty, Text:="=",
PreserveFormatting:=False
Selection.Fields.Add Range:=myRange, Type:=wdFieldEmpty,
Text:="numpages", PreserveFormatting:=False
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:="-1"
Selection.Fields.Update
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
end sub
I get the mistake.
Wherein my mistake?
Thank you very much for help.