zoukankan      html  css  js  c++  java
  • 使用C#在word中插入页眉页脚

     //插入页脚

    1. public void InsertFooter(string footer)  
    2. {  
    3.     if (ActiveWindow.ActivePane.View.Type == WdViewType.wdNormalView ||  
    4.         ActiveWindow.ActivePane.View.Type == WdViewType.wdOutlineView)  
    5.     {  
    6.         ActiveWindow.ActivePane.View.Type = WdViewType.wdPrintView;  
    7.     }  
    8.   
    9.     ActiveWindow.View.SeekView = WdSeekView.wdSeekCurrentPageFooter;  
    10.     this.Application.Selection.HeaderFooter.LinkToPrevious = false;  
    11.     this.Application.Selection.HeaderFooter.Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;  
    12.     ActiveWindow.ActivePane.Selection.InsertAfter(footer);  
    13.   
    14.     //跳出页眉页脚设置  
    15.     ActiveWindow.View.SeekView = WdSeekView.wdSeekMainDocument;  
    16.   
    17. }  


     

    msdn上的方法

      1. foreach (Word.Section wordSection in this.Application.ActiveDocument.Sections)  
      2.            {  
      3.                Word.Range footerRange = wordSection.Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;  
      4.                footerRange.Font.ColorIndex = Word.WdColorIndex.wdDarkRed;  
      5.                footerRange.Font.Size = 20;  
      6.                footerRange.Text = "页脚 页脚";  
      7.            }  
      8.   
      9.            foreach (Word.Section section in this.Application.ActiveDocument.Sections)  
      10.            {  
      11.                Word.Range headerRange = section.Headers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary].Range;  
      12.                headerRange.Fields.Add(headerRange, Word.WdFieldType.wdFieldPage);  
      13.                headerRange.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphRight;  
      14.            } 
  • 相关阅读:
    ansible常用模块及参数(1)
    ansible搭建wordpress,安装nfs和rsync
    ElasticSearch 集群
    kibana数据操作
    ElasticSearch 交互使用
    Elasticsearch的基础安装
    Elasticsearch的简介
    redis数据审计
    redis数据迁移
    redis集群节点添加与删除
  • 原文地址:https://www.cnblogs.com/rr163/p/3922349.html
Copyright © 2011-2022 走看看