用javascript操作word文档

时间:2010-03-26 17:41:31  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:th = "filepath";word.Documents.Open(path);range = word.ActiveDocument.Bookmarks("bookmark").Range;range.InsertBefore("哈哈哈哈哈哈"); 2、把word文件转成html文件<script language=javascript>function saveword(){var oWordApp=new ActiveXObject("Word.Application");var oD...
  正文:

1、 向word中写入内容

首先在word中设置书签,如书签名为bookmark,JavaScript中可以这样写

var word;
word = new ActiveXObject("Word.Application");
var range = word.Range;
word.Visible = true;
var path = "filepath";
word.Documents.Open(path);
range = word.ActiveDocument.Bookmarks("bookmark").Range;
range.InsertBefore("哈哈哈哈哈哈");

2、把word文件转成html文件

<script language=javascript>
function saveword(){
var oWordApp=new ActiveXObject("Word.Application");
var oDocument=oWordApp.Documents.Open("C:doc2htmlx.doc");
oDocument.SaveAs("C:test.htm", 8)
oWordApp.Quit();
}
</script>
</HEAD>
<BODY>
Click the "save" button to save the file "C:test.doc" to "C:test.htm":
<input type=button onclick="saveword()" value=save>

</BODY>
</HTML>
 

"用javascript操作word文档"由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/JavaScript/13376.html


关键字:

关于《用javascript操作word文档》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td