【问题标题】:Different First Page in a document using microsoft office interop word in c#在c#中使用microsoft office interop word的文档中的不同首页
【发布时间】:2013-03-27 09:25:06
【问题描述】:

如何使用 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");   

【问题讨论】:

    标签: c# winforms ms-office office-interop


    【解决方案1】:

    试试这个 -

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-04
      • 2011-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多