熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Javascript >> 正文

用javascript操作word文檔

2013-11-23 17:57:05  來源: Javascript 

   向word中寫入內容

  首先在word中設置書簽如書簽名為bookmarkjavascript中可以這樣寫

  var word;
word = new ActiveXObject(WordApplication);
var range = wordRange;
wordVisible = true;
var path = filepath;
wordDocumentsOpen(path);
range = wordActiveDocumentBookmarks(bookmark)Range;
rangeInsertBefore(哈哈哈哈哈哈);

  把word文件轉成html文件

  <script language=javascript>
function saveword(){
var oWordApp=new ActiveXObject(WordApplication);
var oDocument=oWordAppDocumentsOpen(C:\\dochtml\\xdoc);
oDocumentSaveAs(C:\\ )
oWordAppQuit();
}
</script>
</HEAD>
<BODY>
Click the save button to save the file C:\testdoc to C:\:
<input type=button onclick=saveword() value=save>

</BODY>
</HTML>


From:http://tw.wingwit.com/Article/program/Java/Javascript/201311/25418.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.