ho guardato here e here e hereCome aggiungere una "Pagina X di Y" piè di pagina per Word2007 doc come sto generando usando C#
ho provato questo:
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);
}
}
E questo:
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;
}
}
Ho registrato questa macro VBA, ma non sembra essere utile.
Sub Macro1()
'
' Macro1 Macro
'
'
WordBasic.ViewFooterOnly
ActiveDocument.AttachedTemplate.BuildingBlockEntries("Bold Numbers 3"). _
Insert Where:=Selection.Range, RichText:=True
End Sub
Niente di quello che ho provato ha funzionato abbastanza per me interamente (mi sono avvicinato un po '). Fatemi sapere se qualcosa sulla domanda non è chiara.
Hai mai funzionato? Sto cercando di fare la stessa cosa. –
@Christopher Mahan, mi dispiace, ho smesso di provare ad un certo punto e ho deciso di emettere il codice LaTeX e compilare quello invece. Era abbastanza buono per me. Se risolvi questo, allora darei volentieri un'occhiata alla risposta. Posso suggerire di bruciare parte della tua reputazione sulla taglia. Impostalo in alto ma spiega cosa ti serve. –