【发布时间】:2016-07-30 19:15:58
【问题描述】:
我需要更改目录的范围,以便我可以从 Word 文档的第二页开始。谁能帮我设置范围?
下面的代码是我目前拥有的范围,但这会在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;
【问题讨论】:
-
尝试在第一页末尾插入分页符。
标签: c# .net ms-word office-interop