word中如何设置文档不同部分页眉页脚内容不同?修改页眉和页脚的最快方法是什么?

来源:百度知道 编辑:UC知道 时间:2024/05/18 05:33:35
明天考试用,尽量写简单详细步骤,多谢提供者!

private void SetHeadersFooters(string file)
{
System.Object nothing = System.Reflection.Missing.Value;
Word.Application oApp = new Word.Application();
oApp.Visible = true;
object wordPath = file;
Word.Document oDoc = oApp.Documents.Open( ref wordPath, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing, ref nothing,ref nothing, ref nothing );
Word.Section oSel = null;
Word.Range oPageStart = null;
int iPage;
int iTotalPages;
int iSection;

iTotalPages = oDoc.ComputeStatistics(Word.WdStatistic.wdStatisticPages, ref nothing);

//Retrieve the headers and footers on each page

iSection = 0;
for( iPage = 1; iPage<=iTotalPages;++iPage)
{
//Go to the page represented by the page number iPage and
//retrieve its section
object which = Word.WdGoToDirection.wdGoToAbsolute;