Adding document property field to footer removes existing page numbering

后端 未结 3 438
情书的邮戳
情书的邮戳 2021-01-28 06:54

I am tying to stamp a document variable field in the footer of every page in a document. I have figured out how to add the field. However, in doing so, the page numbering fiel

3条回答
  •  情书的邮戳
    2021-01-28 07:24

    If that is how you want the new field positioned, then try something like this ...

    Dim docSection As word.Section, sectionFooter As word.HeaderFooter
    Dim rng As word.Range
    For Each docSection In ActiveDocument.Sections
        For Each sectionFooter In docSection.Footers
            Set rng = sectionFooter.Range
            rng.InsertParagraphAfter
            rng.Collapse wdCollapseEnd
            rng.Font.Size = 8
            rng.Font.Name = "Arial"
            rng.Fields.Add Range:=rng, Type:=wdFieldEmpty, Text:="DOCVARIABLE  ndGeneratedStamp", PreserveFormatting:=False
        Next
    Next
    

提交回复
热议问题