几个javascript操作word的参考代码
作者:bea
代码如下: /* 给几个js写word的参考: this.Word.Selection.Font.Size = 16; //字体大小 this.Word.Selection.Font.Bold = true; //是否加粗 this.Word.Selection.ParagraphFormat.Alignment = 2; //0左对齐,1居中,2右对齐,数字只能0-9,慢慢试吧 this.Word.Selection.InsertRowsB
代码如下:
/*
给几个js写word的参考:
this.Word.Selection.Font.Size = 16; //字体大小
this.Word.Selection.Font.Bold = true; //是否加粗
this.Word.Selection.ParagraphFormat.Alignment = 2; //0左对齐,1居中,2右对齐,数字只能0-9,慢慢试吧
this.Word.Selection.InsertRowsBelow(1); //下面加入一行
this.Word.Selection.MoveRight(1); //光标右移
this.Word.Selection.TypeText(string); //只能写string
this.Word.Selection.MoveDown(); //光标下移
this.Word.Selection.EndKey(); //光标移动到末尾
this.Word.ActiveDocument.Sections(1).Headers(1).Range.InsertAfter(string); //写页眉,结尾处写
this._LoadData = function () {
//替换函数,用于替换$strFld$类型的文本
function replace( Range, strFld ) {
//[FindText], [MatchCase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap], [Format], [ReplaceWith], [Replace], [MatchKashida], [MatchDiacritics], [MatchAlefHamza], [MatchControl]
Range.Find.Execute( "$"+strFld+"$", true, false, false, false, false, true, wdFindContinue, false, getElValue("l"+strFld) )
}
//初始化Word控件
this._InitWord = function ()
{
try{
this.Word = new ActiveXObject("Word.Application");
this.Word.visible = true;
this.Doc = this.Word.Documents.Open( this.TemplatePath );
this.Doc.Activate();
this.Range = this.Doc.Range();
return true
} catch(e) {
//TODO: 如果用户手动取消ActiveX的运行,则会留一WINWORD.EXE的进程。
//除非"设为可信站点,并在自定义级别里将第二项启用",则不会出现启用ActiveX的对话框。
try {
if ( this.Doc ) { this.Doc.Close(0) };
if ( this.Word ) { this.Word.Quit() }
}
catch (e){}
return false
}
}
*/
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 浅谈javascript 面向对象编程
- 小议javascript 设计模式 推荐
- JavaScript 组件之旅(四):测试 JavaScript 组件
- JavaScript 组件之旅(三):用 Ant 构建组件
- JavaScript 组件之旅(二)编码实现和算法
- JavaScript 组件之旅(一)分析和设计
- js 数组实现一个类似ruby的迭代器
- jquery 操作单选框,复选框,下拉列表实现代码
- javascript获得CheckBoxList选中的数量
- 基于jQuery的日期选择控件
- javascript 读取XML数据,在页面中展现、编辑、保存的实现
- Ajax+Json 级联菜单实现代码
- DIV+CSS+JS 变灰弹出层
- javascript 关于# 和 void的区别分析
- 用Greasemonkey 脚本收藏网站会员信息到本地
- javascript 实现划词标记划词搜索功能
- 解决jquery .ajax 在IE下卡死问题的解决方法
- 解决表单中第一个非隐藏的元素获得焦点的一个方案
- innerhtml用法 innertext用法 以及innerHTML与innertext的区别