js html保存word文档,用jscript实现新建和保存一个word文档

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值