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

Javascript
阻止JavaScript事件冒泡传递(cancelBubble 、stopPropagation)
(转载)JavaScript中匿名函数,函数直接量和闭包
简单的无缝滚动程序-仅几行代码
Javascript中的数学函数集合
javascript之大字符串的连接的StringBuffer 类
javascript之对系统的toFixed()方法的修正
用javascript实现自定义标签
js在客户端验证密码强度,兼容FireFox和IE
javascript背景颜色按时变换
脚本分析、压缩、混淆工具 JSA新版本发布,压缩效率提高大约10%
javascript语句中的CDATA标签的意义
用javascript实现分割提取页面所需内容
网上抓的一个特效
js之点击 超连接,提示一个层.点击空白.层消失
模拟用户操作Input元素,不会触发相应事件
弹出广告特效代码(一个IP只弹出一次)
(仅IE下有效)关于checkbox 三态
JavaScript Archive Network 集合
关于__defineGetter__ 和__defineSetter__的说明
textContent在Firefox下与innerText等效的属性

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


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