NTKO word在线文本编辑控件写页眉页脚

1 篇文章 0 订阅
 


                //Section.Footers 属性
                //返回一个 HeadersFooters 集合,该集合代表指定节的页脚

                //Section.Headers 属性
                //返回一个 HeadersFooters 集合,该集合代表指定节的页眉

                //WdHeaderFooterIndex 枚举
                //返回文档或节中的指定页眉或页脚。
                //名称 值 描述
                //wdHeaderFooterEvenPages 3 返回偶数页上的所有页眉或页脚。
                //wdHeaderFooterFirstPage 2 返回文档或节中的第一个页眉或页脚。
                //wdHeaderFooterPrimary 1 返回文档或节中除第一页外所有页上的页眉或页脚。

                //Sections 集合包括所选内容、范围或文档中的所有节。
                //Section 代表所选内容、范围或文档中的一节

                //View 包含窗口或窗格的视图属性(如全部显示、域底纹和网格线)。
                //SeekView 属性可查看批注、尾注、脚注或者文档页眉或页脚

                //WdSeekView 枚举
                //指定要在页面视图中显示的文档元素。
                //名称 值 描述
                //wdSeekCurrentPageFooter 10 当前页页脚。
                //wdSeekCurrentPageHeader 9 当前页页眉。
                //wdSeekEndnotes 8 尾注。
                //wdSeekEvenPagesFooter 6 偶数页页脚。
                //wdSeekEvenPagesHeader 3 偶数页页眉。
                //wdSeekFirstPageFooter 5 首页页脚。
                //wdSeekFirstPageHeader 2 首页页眉。
                //wdSeekFootnotes 7 脚注。
                //wdSeekMainDocument 0 主文档。
                //wdSeekPrimaryFooter 4 主页脚。
                //wdSeekPrimaryHeader 1 主页眉。


  WdPageNumberAlignment 枚举
                //指定要应用于页码的对齐方式。
                //名称 值 描述
                //wdAlignPageNumberCenter 1 居中。
                //wdAlignPageNumberInside 3 只在页脚内部左对齐。
                //wdAlignPageNumberLeft 0 左对齐。
                //wdAlignPageNumberOutside 4 只在页脚外部右对齐。
                //wdAlignPageNumberRight

  //HeadersFooters 集合对象
  //HeaderFooter 对象的集合,这些对象代表文档的指定节中的页眉或页脚

                //Shapes.AddTextEffect 方法
                //在绘图画布上添加一个“艺术字”图形。返回一个 Shape 对象,该对象代表“艺术字”,并将其添加至 CanvasShapes 集合。

                //Window.ActivePane 属性
                //返回 Pane 对象,该对象代表指定窗口的活动窗格;一个代表 Window 对象的变量。

                //ActiveWindow 属性 返回开发环境中活动的窗口

                //Application.ActiveDocument 属性
                //返回一个 Document 对象,该对象代表活动文档。如果没有打开的文档,就会导致出错。

                //Range 对象
                //代表文档中的一个连续区域。每个 Range 对象由一个起始字符位置和一个终止字符位置定义。


            //WdParagraphAlignment 枚举
            //指定段落的对齐方式。
            //名称 值 描述
            //wdAlignParagraphCenter 1 居中。
            //wdAlignParagraphDistribute 4 段落字符被分布排列,以填满整个段落宽度。
            //wdAlignParagraphJustify 3 完全两端对齐。
            //wdAlignParagraphJustifyHi 7 两端对齐,字符高度压缩。
            //wdAlignParagraphJustifyLow 8 两端对齐,字符轻微压缩。
            //wdAlignParagraphJustifyMed 5 两端对齐,字符中度压缩。
            //wdAlignParagraphLeft 0 左对齐。
            //wdAlignParagraphRight 2 右对齐。
            //wdAlignParagraphThaiJustify 9 按照泰语格式布局两端对齐。


     //ParagraphFormat 对象
     //代表段落的所有格式。
     //说明:使用 Format 属性可返回一个或多个段落的 ParagraphFormat 对象。ParagraphFormat 属性返回所选内容、范围、样式、 Find 对象或 Replacement

对象的 ParagraphFormat 对象。
 
            //Selection.TypeText 方法
            //插入指定的文本

            //Fields.Add 方法
            //将 Field 对象添加到 Fields 集合


       代码示例:

 function ADDReport()
        {
            try
            {
                var ActiveDocument = form1.TANGER_OCX.ActiveDocument;
                ActiveDocument.Sections(1).Headers(2).Range.Borders(-3).LineStyle = 0;
                ActiveDocument.Sections(1).Footers(2).Range.Delete();

                insertPageFooter();
                

                for (i=1;i<=ActiveDocument.Sections.Count ; i++)
                {
                    ActiveDocument.Sections(i).Range.Select();
                    ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 10;

                    ActiveDocument.Sections(i).Headers(1).Range.Borders(-3).LineStyle = 0;
                    ActiveDocument.Sections(i).Footers(1).Range.Delete();
                    
                    insertPageFooter();
                    
                }
            }
            catch(err){
                alert("ADDReport errir:" + err.number + ":" + err.description);
            } 
        } 
        function insertPageFooter()
        {
            var ActiveDocument = form1.TANGER_OCX.ActiveDocument;
            var App=form1.TANGER_OCX.ActiveDocument.Application; 

            ActiveDocument.ActiveWindow.ActivePane.View.SeekView=10;

            
            App.Selection.ParagraphFormat.Alignment=1;

            App.Selection.TypeText("说明 第");
            App.Selection.Fields.Add(App.Selection.Range,33);
            App.Selection.TypeText("页 ");

            App.Selection.TypeText("<% =GetProjCheckCode() %>");
            ActiveDocument.ActiveWindow.ActivePane.View.SeekView = 0;
        }  


 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值