I need to change the Range of a table of contents so that i can start on the second page of a word document. Anyone can help me with setting the range?
The code below is the range that i currently have, but this will generate the table of contents at the very begging of the word document, I need to insert it on the second page.
object start = oWord.ActiveDocument.Content.Start;
Word.Range rangeForTOC = oDoc.Range(ref oMissing, ref start);
This is what I'm testing this with:
object gotoPage1 = Word.WdGoToItem.wdGoToPage;
object gotoNext1 = Word.WdGoToDirection.wdGoToAbsolute;
object gotoCount1 = null;
object gotoName1 = 1;
oWord.Selection.GoTo(ref gotoPage1, ref gotoNext1, ref gotoCount1, ref gotoName1);
//Insert a blank page
oWord.Selection.InsertNewPage();
oWord.Selection.InsertNewPage();
object what = Microsoft.Office.Interop.Word.WdGoToItem.wdGoToPage;
object which = Microsoft.Office.Interop.Word.WdGoToDirection.wdGoToAbsolute;
object count = 2; //change this number to specify the start of a different page
oWord.Selection.GoTo(ref what, ref which, ref count, ref oMissing);
Object beginPageTwo = oWord.Selection.Range.Start;
// This gets the start of the page specified by count object
Word.Range rangeForTOC = oDoc.Range(ref oMissing, ref beginPageTwo);
object oTrueValue = true;