在C#中使用Microsoft Office Interop单词的文档中的不同首页 [英] Different First Page in a document using microsoft office interop word in c#

查看:97
本文介绍了在C#中使用Microsoft Office Interop单词的文档中的不同首页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Microsoft.office.interop.word在文档中创建不同的首页页眉和页脚.

How can i create a different first page header and footer in a document using Microsoft.office.interop.word.

我尝试了以下代码,但仅在第一页中,页眉和页脚即将到来. 我想用另一种方式(第一页不应有页眉和页脚). 谁能帮帮我吗 ?我尝试了很多.

I have tried the following code but only in the first page, header and footer is coming. I want it in the other way(first page shouldn't have header and footer). can any one Please help me ? i tried a lot.

 Microsoft.Office.Interop.Word.Application w = new icrosoft.Office.Interop.Word.Application();
 Microsoft.Office.Interop.Word.Document doc;
 w.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = -1;
 doc.ActiveWindow.ActivePane.View.SeekView = WdSeekView.wdSeekCurrentPageHeader;
 doc.ActiveWindow.Selection.TypeText("HEader Text");   

推荐答案

尝试一下-

 Microsoft.Office.Interop.Word.Application w = new icrosoft.Office.Interop.Word.Application();
 Microsoft.Office.Interop.Word.Document doc;
 doc = w.ActiveDocument;
 doc.PageSetup.DifferentFirstPageHeaderFooter = -1;

 // Setting Different First page Header & Footer
 doc.Sections[1].Headers[WdHeaderFooterIndex.wdHeaderFooterFirstPage].Range.Text = "First Page Header";
 doc.Sections[1].Footers[WdHeaderFooterIndex.wdHeaderFooterFirstPage].Range.Text = "First Page Footer";

 // Setting Other page Header & Footer
 doc.Sections[1].Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "Other Page Header";
 doc.Sections[1].Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "Other Page Footer";

这篇关于在C#中使用Microsoft Office Interop单词的文档中的不同首页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆