2013-03-27 68 views
0

如何在使用Microsoft.office.interop.word的文档中创建不同的第一页页眉和页脚。在c中使用microsoft office interop word的文档中的第一页不同#

我试过下面的代码,但只在第一页,页眉和页脚即将到来。 我想以另一种方式(第一页不应该有页眉和页脚)。 可以任何一个请帮帮我吗?我尝试了很多。

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"); 

回答

4

试试这个 -

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"; 
+0

它解决了问题,谢谢 – Jpaul 2013-03-28 12:07:32

相关问题