标签:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> function openWord(filename){ try { var wrd=new ActiveXObject("word.Application"); wrd.visible=true; wdoc=wrd.Documents.Open(filename); range =wrd.ActiveDocument.Bookmarks("dname").Range; range.Text="title"; //输出会议时间 range =wrd.ActiveDocument.Bookmarks("dage").Range; range.Text="meetingTime"; //输出会议主持人 range =wrd.ActiveDocument.Bookmarks("dsex").Range; range.Text="compere"; //输出出席人员 range =wrd.ActiveDocument.Bookmarks("dlxfs").Range; range.Text="attend"; //输出会议内容 range =wrd.ActiveDocument.Bookmarks("djtzz").Range; range.Text="content";
wdoc.Application.Printout(); wrd=null; } catch(e){} } </script>
(2)在页面的适当位置添加一个用于选择文件的文件域,名称为file1,代码如下: <input name="file1" type="file" class="textarea" id="file1" size="35"> (3)在“打开Word并打印”按钮的onClick事件中调用自定义JavaScript函数openWord(),打开指定的Word文档并打印。关键代码如下。 <input name="Submit2" type="button" class="btn_grey" onClick="openWord(file1.value)" value="打开Word并打印">
|
标签:
原文地址:http://www.cnblogs.com/install/p/4417563.html