我需要更改目錄的範圍,以便我可以在文檔的第二頁上啓動。任何人都可以幫助我設置範圍?設置範圍在文檔的第二頁上啓動
下面的代碼是我現在有的範圍,但是這將在word文檔的乞求中生成目錄,我需要將它插入第二頁。
object start = oWord.ActiveDocument.Content.Start;
Word.Range rangeForTOC = oDoc.Range(ref oMissing, ref start);
這就是我與測試此:
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;
嘗試在第一頁的末尾插入分頁符。 – user3165438 2014-09-28 09:23:01