【发布时间】:2011-09-21 15:45:14
【问题描述】:
我试过了:
private void AddFooters()
{
foreach (Word.Section wordSection in this.WordDoc.Sections)
{
object fieldEmpty = Word.WdFieldType.wdFieldEmpty;
object autoText = "AUTOTEXT \"Page X of Y\" ";
object preserveFormatting = true;
wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Fields.Add(
wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range,
ref fieldEmpty, ref autoText, ref preserveFormatting);
}
}
还有这个:
private void AddFooters()
{
foreach (Word.Section section in this.WordDoc.Sections)
{
Word.Range footerRange = section.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
this.WordDoc.ActiveWindow.Selection.TypeText("Page ");
footerRange.Fields.Add(footerRange, Word.WdFieldType.wdFieldPage);
this.WordDoc.ActiveWindow.Selection.TypeText(" of ");
footerRange = section.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
footerRange.Fields.Add(footerRange, Word.WdFieldType.wdFieldNumPages);
footerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;
}
}
我录制了这个 VBA 宏,但它似乎没有帮助。
Sub Macro1()
'
' Macro1 Macro
'
'
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Bold Numbers 3"). _
Insert Where:=Selection.Range, RichText:=True
End Sub
我尝试过的任何事情都没有完全对我有用(我有点接近)。 如果问题不清楚,请告诉我。
【问题讨论】:
-
你有没有得到这个工作?我也想做同样的事情。
-
@Christopher Mahan,对不起,我在某个时候停止了尝试,并决定发出 LaTeX 代码并编译它。这对我来说已经足够好了。如果你解决了这个问题,那么我很乐意看看答案。我可以建议在赏金上烧掉你的一些声誉。设置得高一些,但一定要说明你需要什么。
标签: c# .net-4.0 ms-word office-interop page-numbering