当前位置:文档之家› js转word并实现另存

js转word并实现另存

try {
var fileName = SaveName; //文件名
var areaRes = document.getElementById(tbName); //指定要输入区域
var wordObj = new ActiveXObject("Word.Application"); //指定输出类型
var docObj = wordObj.Documents.Add("", 0, 1);
var oRange = docObj.Range(0, 1);
var sel = document.body.createTextRange();
sel.moveToElementText(areaRes);
sel.select();
sel.execCommand("Copy");
oRange.Paste();
wordObj.Application.Visible = true;


var filePath=showDialog();
if(filePath) docObj.SaveAs( filePath);



function showDialog(){
var dial=wordObj.FileDialog(2);
return dial.show()==-1?dial.SelectedItems(1):'';
}

}catch (e) {
print("Nested catch caught " + e);
}

相关主题
文本预览
相关文档 最新文档