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

Javascript
推荐js实现商品分类到搜索栏友好提示(人机交互)
attachEvent的使用方法与传递参数[IE|firefox]
用javascript实现鼠标框选
一个不错的动感导航菜单
JavaScript网页制作特殊效果用随机数
一段非常好的滑动门[可感应触发或点击触发]兼容IE7 IE6 FireFox Opera
js实现的的 文字自动''到google search框
JS值当前DIV的ID值的代码
在javascript中,如果删除二维数组中重复的元素
一个用js实现的页内搜索代码
不用MOUSEMOVE也能滑动啊
asp 的 分词实现代码
更正确的asp冒泡排序
用Javscript实现表单复选框的全选功能
向fckeditor编辑器插入指定代码的方法
javascript实现 在光标处插入指定内容
如何实现动态删除javascript函数
javascript父子通信
JS获取scrollHeight问题想到的标准问题
從博客網扣了一個效果出來

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 93 ::
收藏到网摘: 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