|
我在表单中添加一个按钮,按钮的功能是打开固定格式的word,<br>
创建word的js代码:<br>
var myDocApp=null;<br>myDocApp =new ActiveXObject("word.Application"); <br>myDocApp.Application.Visible = true; <br>var myDoc = myDocApp.Documents.Add();<br>
<br>
<br>myDocApp.Selection.ParagraphFormat.Alignment=1 <br>myDocApp.Selection.Range.Bold=true;<br>myDocApp.Selection.Font.Size=22;<br>myDocApp.Selection.Text="请假申请单"<br>myDocApp.Selection.insertAfter("\n");<br>myDocApp.Selection.MoveRight(1,10); <br>myDocApp.Selection.TypeParagraph();<br>myDocApp.Selection.Font.Bold=false;<br>myDocApp.Selection.Font.Size=12;<br>
<br>
<br>
<br>var myTable0=myDoc.Tables.Add(myDocApp.Selection.Range,3,4);<br>
<br>myTable0.cell(1,1).Range.Text="请假人"<br>myTable0.cell(1,2).Range.Text="" <br>
<br>myTable0.cell(1,3).Range.Text="请假时间"<br>myTable0.cell(1,4).Range.Text="2006-2-10"<br>
<br>
<br>myTable0.cell(2,1).Range.Text="工号"<br>myTable0.cell(2,2).Range.Text="32412"<br>
<br>
<br>myTable0.cell(2,3).Range.Text="填表时间"<br>myTable0.cell(2,4).Range.Text="2006-2-9"<br>
<br>
<br>myTable0.cell(3,1).Range.Text="请假原因"<br>myTable0.cell(3,2).Range.Text="感冒"<br>
<br>
<br>myTable0.cell(3,3).Range.Text="处理方式"<br>myTable0.cell(3,4).Range.Text="病假"<br>
<br>var range=myDocApp.ActiveDocument.Content;<br>
range.Collapse(0); <br>
range.insertAfter("\n");<br>
range=myDocApp.ActiveDocument.Content;<br>
range.Collapse(0);<br>
<br>
<br>var myTable1=myDoc.Tables.Add(range,2,1);<br>
<br>myTable1.cell(1,1).Range.Text="正文"<br>var wdRowHeightExactly<br>myTable1.Rows(2).SetHeight ( 200, wdRowHeightExactly )<br>myTable1.cell(2,1).Range.Text="天气突然降温,着凉引发感冒!!"<br>
<br>
<br>
<br>var range=myDocApp.ActiveDocument.Content;<br>
range.Collapse(0); <br>
range.insertAfter("\n");<br>
range=myDocApp.ActiveDocument.Content;<br>
range.Collapse(0);<br>
<br>var myTable2=myDoc.Tables.Add(range,1,2);<br>
<br>myTable2.Columns(1).SetWidth(320,2);<br>myTable2.cell(1,1).Range.Text=" 申请人签名" //空格勿删<br>
// myTable2.cell(1,2).Range.Text="申请人的签名"<br>
myTable2.cell(1,2).Select();<br>
myDocApp.Selection.InlineShapes.AddPicture("E:\\user.gif");<br>
<br>var range=myDocApp.ActiveDocument.Content;<br>
range.Collapse(0); <br>
range.insertAfter("\n");<br>
range=myDocApp.ActiveDocument.Content;<br>
range.Collapse(0);<br>
<br>
<br>var myTable3=myDoc.Tables.Add(range,3,4);<br>
<br>myTable3.cell(1,1).Range.Text="组长意见"<br>myTable3.cell(1,2).Range.Text="同意"<br>
<br>myTable3.cell(1,3).Range.Text="签名"<br>myTable3.cell(1,4).Range.Text="组长的签名"<br>
<br>
<br>myTable3.cell(2,1).Range.Text="部门意见"<br>myTable3.cell(2,2).Range.Text="同意"<br>
<br>
<br>myTable3.cell(2,3).Range.Text="签名"<br>myTable3.cell(2,4).Range.Text="主任的签名"<br>
<br>
<br>myTable3.cell(3,1).Range.Text="厂领导意见"<br>myTable3.cell(3,2).Range.Text="同意"<br>
<br>
<br>myTable3.cell(3,3).Range.Text="签名"<br>myTable3.cell(3,4).Range.Text="厂领导签名"<br>
<br>
<br>
<br>
try{<br>
myDocApp.ActiveDocument.SaveAs("e:\\JaveToWord.doc");<br>
}catch(exception){<br>
alert("浏览器安全设置过高,保存文件到本地失败");<br>
myDocApp.Documents.close();<br>
myDocApp.Application.quit();<br>
myDocApp=null;<br>
window.close();<br>
}<br>
//myDocApp.Documents.close();<br>
//myDocApp.Application.quit();<br>
//myDocApp=null;<br>
但是我如何在提交表单过程中把表单上的值传递到word的某一个区域中呢,谢谢!<br>
<br>
|
|