本文介绍了如何在microsoft interop中更改word中的起始页码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用下面提供的代码,当我按下按钮时,页面已编号.但是,如果我选择了除第一页以外的任何页面,则该页码将成为起始页码,即在选择第 2 页时单击该按钮会将第 1 页上的编号设置为2".我怎样才能让它在任何情况下都从第一页开始.

With the code provided below, when I press a button, The pages are numbered. However if I have selected any page other than the first page that page number becomes the starting page number i.e. Clicking the button while selecting page 2 sets the number on page 1 to "2". How can I make it start at page one in any circumstance.

Microsoft.Office.Interop.Word.Document Doc = //Gets current Document
oject CurrentPage = Microsoft.Office.Interop.Word.WdFieldType.wdFieldNumPages;
object oMissing = System.Reflection.Missing.Value;
//Gets the Header
Doc.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekPrimaryHeader;
//Adds the page number
Doc.ActiveWindow.Selection.Fields.Add(
Doc.ActiveWindow.Selection.Range, ref CurrentPage, ref oMissing, ref oMissing);

推荐答案

对象 HeaderFooter 包含一个 PageNumbers 属性,该属性有几个有趣的属性,包括 StartingNumber.

The object HeaderFooter contains a PageNumbers property that has several interesting properties, including StartingNumber.

请参阅此处,了解有关如何检索的一些信息正确的 HeaderFooter 实例.

see here for some information on how to retrieve the correct HeaderFooter instance.

这篇关于如何在microsoft interop中更改word中的起始页码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 09:02