2013-03-27 82 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

相關問題