当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 用jscript实现新建和保存一个word文档

Javascript
用js实现终止浏览器对页面HTML的继续解析即停止解析 兼容firefox
Auntion-TableSort国人写的一个javascript表格排序的东西
javascript实现二分查找法实现代码
利用ASP发送和接收XML数据的处理方法与代码
兼容ie和firefox的鼠标经过(onmouseover和onmouseout)实现--简短版
javascript之文本框输入四个数字自动加空格的脚本
比较简单实用的使用正则三种版本的js去空格处理方法
比较简洁的JavaScript 实时显示时间的脚本 修正版
JavaScript检查表单是否为空的函数
window.open被浏览器拦截后的自定义提示效果代码
javascript跟随鼠标的文字带滚动效果
让插入到 innerHTML 中的 script 跑起来的代码
Flash+XML滚动新闻代码 无图片 附源码下载
javascript(js) join函数使用方法介绍
表格头固定而列可滚动的效果
document.designMode的功能与使用方法介绍
精解window.setTimeout()&window.setInterval()使用方式与参数传递问题!
用javascript实现的电信铁通(网通)自动跳转源代码
用js查找法实现当前栏目的高亮显示的代码
javascript之鼠标拖动位置互换效果代码

Javascript 中的 用jscript实现新建和保存一个word文档


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 212 ::
收藏到网摘: n/a

Demonstration script that retrieves network adapter data from a computer,
displays that data in a Microsoft Word document, and then saves the
document as C:\Scripts\Word\Testdoc.doc.
复制代码 代码如下:

Set objWord = CreateObject("Word.Application")
objWord.Caption = "Test Caption"
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Font.Name = "Arial"
objSelection.Font.Size = "18"
objSelection.TypeText "Network Adapter Report"
objSelection.TypeParagraph()
objSelection.Font.Size = "14"
objSelection.TypeText "" & Date()
objSelection.TypeParagraph()
objSelection.TypeParagraph()
objSelection.Font.Size = "10"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration")
For Each objItem in colItems
objSelection.Font.Bold = True
objSelection.TypeText "ARP Always Source Route: "
objSelection.Font.Bold = False
objSelection.TypeText "" & objItem.ArpAlwaysSourceRoute
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "ARP Use EtherSNAP: "
objSelection.Font.Bold = False
objSelection.TypeText "" & objItem.ArpUseEtherSNAP
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "Caption: "
objSelection.Font.Bold = False
objSelection.TypeText "" & objItem.Caption
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "Database Path: "
objSelection.Font.Bold = False
objSelection.TypeText "" & objItem.DatabasePath
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "Dead GW Detection Enabled: "
objSelection.Font.Bold = False
objSelection.TypeText "" & objItem.DeadGWDetectEnabled
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "Default IP Gateway: "
objSelection.Font.Bold = False
objSelection.TypeText "" & objItem.DefaultIPGateway
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "Default TOS: "
objSelection.Font.Bold = False
objSelection.TypeText "" & objItem.DefaultTOS
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "Default TTL: "
objSelection.Font.Bold = False
objSelection.TypeText "" & objItem.DefaultTTL
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText "Description: "
objSelection.Font.Bold = True
objSelection.Font.Bold = False
objSelection.TypeText "" & objItem.Description
objSelection.TypeParagraph()
objSelection.TypeParagraph()
Next
objDoc.SaveAs("C:\Scripts\Word\testdoc.doc")
objWord.Quit