将文章另存为abc.txt
打开网页:
<body>
<button onclick="newdoc()">转换文档为doc</button>
<script language="JavaScript">
function newdoc(){
var app=new ActiveXObject("Word.Application");
var doc = app.Documents.Open("D:\\csdn\\js\\abc.txt");
var FileName="D:\\csdn\\js\\abc.doc";
var FileFormat=0;
doc.SaveAs(FileName,FileFormat);
doc.Close();
}
</script>
</body>
打开网页:
<body>
<button onclick="newdoc()">转换文档为doc</button>
<script language="JavaScript">
function newdoc(){
var app=new ActiveXObject("Word.Application");
var doc = app.Documents.Open("D:\\csdn\\js\\abc.txt");
var FileName="D:\\csdn\\js\\abc.doc";
var FileFormat=0;
doc.SaveAs(FileName,FileFormat);
doc.Close();
}
</script>
</body>
try{
var wApp = new ActiveXObject("Word.Application")
}catch(e){
alert("没法保存为Word文件,请正确安装Word97");
}
wApp.Documents.Add()
wApp.Selection.ParagraphFormat.Alignment = 1
wApp.Selection.TypeParagraph()
wApp.Selection.Font.Bold = true
wApp.Selection.TypeText(" 一周工作计划安排")
wApp.Selection.TypeParagraph()
wApp.Selection.ParagraphFormat.LeftIndent = wApp.CentimetersToPoints(0)
wApp.Selection.ParagraphFormat.FirstLineIndent = wApp.CentimetersToPoints(0.72/2*2)
wApp.Selection.TypeParagraph()
wApp.Selection.Font.Bold = false
wApp.Selection.ParagraphFormat.Alignment = 0
wApp.Selection.TypeText("星期 一:早上对erp进行修改,以适合门市部的销售模式。 下午:同上")
wApp.Selection.TypeParagraph()
wApp.Selection.TypeText("星期 二:早上对erp进行修改,以适合门市部的销售模式。 下午:同上")
wApp.Selection.TypeParagraph()
wApp.Selection.TypeText("星期 三:早上到门市部进行实地数据采集。 下午:同上")
wApp.Selection.TypeParagraph()
wApp.Selection.TypeText("星期 四:针对门市部饶经理的要求,对erp的销售模块及库存管理模块重新进行修改。")
wApp.Selection.TypeParagraph()
wApp.Selection.TypeText("星期 五:写出分析报告,及数据表汇总表。")
wApp.Selection.TypeParagraph()
wApp.Selection.TypeText("星期 六:写代码")
wApp.Selection.TypeParagraph()
wApp.Selection.ParagraphFormat.Alignment = 2
wApp.Selection.TypeParagraph()
wApp.Selection.Font.Bold = false
wApp.Selection.TypeText("软件部:甘慧兵")
wApp.Selection.TypeParagraph() wApp.Selection.TypeText("2002.7.27")
wApp.Selection.TypeParagraph() wApp.ActiveDocument.SaveAs("c:\\test.doc")
</script>