Hi,
The code below creates the following equation in all the footers in a Word Document:
IF {PAGE} = {PAGENUM} "{AUTHOR}"
Which displays the following in the footer:
Page one: IF 1 = 2 "Author"
Page two: IF 2 = 2 "Author"
I would like this equation to be in it's own field so that "Author" is only displayed on the last page.
This works when I highlight that equation and press Ctrl F9 (i.e. Displays Author on the last page.)
Is there a way to do the Ctrl F9 in Code .... make that equation so that it is it's on field. { IF {PAGE} = {PAGENUM} "{AUTHOR}" }
Any helps would be greatly appreciated.
object collapseDirection = WdCollapseDirection.wdCollapseStart;
object fieldPages = WdFieldType.wdFieldPage;
object fieldNumPages = WdFieldType.wdFieldNumPages;
object fieldMerge = WdFieldType.wdFieldMergeField;
object fieldAuthor = WdFieldType.wdFieldAuthor;
Microsoft.Office.Interop.Word.Range Rng = activeDoc.Sections.Last.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
object txt = string.Empty;
Rng.Fields.Add(Rng, ref fieldAuthor, ref txt, ref preserveFormatting);
Rng.InsertAfter("\"");
Rng.InsertBefore("\"");
Rng.Collapse(ref collapseDirection);
activeDoc.Fields.Add(Rng, ref fieldNumPages, ref txt, ref preserveFormatting);
Rng.InsertBefore(" = ");
Rng.Collapse(ref collapseDirection);
activeDoc.Fields.Add(Rng, ref fieldPages, ref txt, ref preserveFormatting);
Rng.InsertBefore(" IF ");
Rng.Collapse(ref collapseDirection);
The code below creates the following equation in all the footers in a Word Document:
IF {PAGE} = {PAGENUM} "{AUTHOR}"
Which displays the following in the footer:
Page one: IF 1 = 2 "Author"
Page two: IF 2 = 2 "Author"
I would like this equation to be in it's own field so that "Author" is only displayed on the last page.
This works when I highlight that equation and press Ctrl F9 (i.e. Displays Author on the last page.)
Is there a way to do the Ctrl F9 in Code .... make that equation so that it is it's on field. { IF {PAGE} = {PAGENUM} "{AUTHOR}" }
Any helps would be greatly appreciated.
object collapseDirection = WdCollapseDirection.wdCollapseStart;
object fieldPages = WdFieldType.wdFieldPage;
object fieldNumPages = WdFieldType.wdFieldNumPages;
object fieldMerge = WdFieldType.wdFieldMergeField;
object fieldAuthor = WdFieldType.wdFieldAuthor;
Microsoft.Office.Interop.Word.Range Rng = activeDoc.Sections.Last.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;
object txt = string.Empty;
Rng.Fields.Add(Rng, ref fieldAuthor, ref txt, ref preserveFormatting);
Rng.InsertAfter("\"");
Rng.InsertBefore("\"");
Rng.Collapse(ref collapseDirection);
activeDoc.Fields.Add(Rng, ref fieldNumPages, ref txt, ref preserveFormatting);
Rng.InsertBefore(" = ");
Rng.Collapse(ref collapseDirection);
activeDoc.Fields.Add(Rng, ref fieldPages, ref txt, ref preserveFormatting);
Rng.InsertBefore(" IF ");
Rng.Collapse(ref collapseDirection);