wps操作页眉和页脚的一些示例代码

项目中需要用到wps的控件操作文档的页面和页脚,这里把用到的脚本做如下记录

//处理页眉
DocObj.ActiveWindow.Document.PageSetup.DifferentFirstPageHeaderFooter  = true;
DocObj.ActiveWindow.View.SeekView = 9;
DocObj.ActiveWindow.Selection.text  = "文本内容";
DocObj.ActiveWindow.View.SeekView = 0;
  
//所有偶数页的页脚插入图片
var icount = DocObj.BuiltInDocumentProperties(14);
if((icount % 2) != 0){
	DocObj.ActiveWindow.Selection.InsertBreak(7);
}
DocObj.ActiveWindow.Document.PageSetup.OddAndEvenPagesHeaderFooter  = true;
DocObj.ActiveWindow.View.SeekView = 6;
var barcodePath = "C:/Users/pengsy/Pictures/Chrysanthemum.jpg";
DocObj.ActiveWindow.Selection.InlineShapes.AddPicture(barcodePath);
DocObj.ActiveWindow.View.SeekView = 0;

 

你可能感兴趣的:(图片,文字,WPS,页眉,页脚)