【发布时间】:2013-11-20 20:00:50
【问题描述】:
我一直在使用互操作来编辑现有的 Word 文档。我的问题是;我需要在文档页脚中添加一个新字段,令我惊讶的是,它删除了现有的页脚字段,因此只保留了新添加的字段。没有关于它的明确文档,结果相当出乎意料。以下是我的代码:
foreach (Microsoft.Office.Interop.Word.Section wordSection in wordDocument.Sections)
{
Microsoft.Office.Interop.Word.HeadersFooters footers = wordSection.Footers;
foreach (HeaderFooter footer in footers)
{
footer.Range.Select();
Field f = appWord.ActiveWindow.Selection.Fields.Add(appWord.ActiveWindow.Selection.Range);
appWord.Selection.TypeText(footerText);
}
}
【问题讨论】:
-
好的,我认为如果您能提供一个现有页脚包含的内容以及您希望它看起来像什么的示例,将会有所帮助。例如,假设您现有的页脚在页脚的左侧包含文本“myexistingfooter”。你的页脚应该是什么?