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

Javascript
一段超强的javascript代码解密方法
感觉很流畅的js实现的键盘控制(带惯性)
脚本安需导入(装载)的三种模式的对比
用js实现控制内容的向上向下滚动效果
非常不错的一个JS分页效果代码,值得研究
又一个漂亮的导航栏的下拉菜单
特想搞点新的创意出来-立体方块
得到当前行的值的javascript代码
通用的加入收藏夹代码支持IE Firefox等浏览器
javascript状态栏的字符先杂乱出现再排列组合的代码
js之弹出式窗口代码生成器
javascript实现的制作特殊字的脚本
一个加载js文件的小脚本
用JavaScript检查大写键(Caps Lock)是否打开的脚本
javascript中的几个运算符
ECMAScript 基础知识
你需要知道的JavsScript可以做什么?
JavaScript 编程引入命名空间的方法
javascript延时重复执行函数 lLoopRun.js
javascript之函数直接量(function(){})()

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


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