【发布时间】:2022-01-14 07:08:04
【问题描述】:
我想在文档中每一页的页脚中标记一个文档变量字段。我已经弄清楚如何添加该字段。但是,这样做时,页脚中已经存在的页码字段将被禁用,只留下文本,不再充当动态页码。
这是我添加字段的代码,但以某种方式禁用了页码。 (“sectionFooter.Range.Text = sectionFooter.Range.Text +”“”行是我能找到的唯一方法,甚至可以让页码仍然显示):
For Each docSection In ActiveDocument.Sections
For Each sectionFooter In docSection.Footers
sectionFooter.Range.Collapse wdCollapseEnd
sectionFooter.Range.Text = sectionFooter.Range.Text + " "
sectionFooter.Range.Collapse wdCollapseEnd
Dim newPP As Paragraph
Set newPP = sectionFooter.Range.Paragraphs.Add()
newPP.Range.Font.Size = 8
newPP.Range.Font.Name = "Arial"
ActiveDocument.Fields.Add Range:=newPP.Range, Type:=wdFieldEmpty, Text:="DOCVARIABLE ndGeneratedStamp", preserveformatting:=False
Next
Next
【问题讨论】: