用jscript实现新建和保存一个word文档_Javascript教程-查字典教程网
用jscript实现新建和保存一个word文档
用jscript实现新建和保存一个word文档
发布时间:2016-12-30 来源:查字典编辑
摘要:Demonstrationscriptthatretrievesnetworkadapterdatafromacomputer,displa...

Demonstrationscriptthatretrievesnetworkadapterdatafromacomputer,

displaysthatdatainaMicrosoftWorddocument,andthensavesthe

documentasC:ScriptsWordTestdoc.doc.

复制代码 代码如下:

SetobjWord=CreateObject("Word.Application")

objWord.Caption="TestCaption"

objWord.Visible=True

SetobjDoc=objWord.Documents.Add()

SetobjSelection=objWord.Selection

objSelection.Font.Name="Arial"

objSelection.Font.Size="18"

objSelection.TypeText"NetworkAdapterReport"

objSelection.TypeParagraph()

objSelection.Font.Size="14"

objSelection.TypeText""&Date()

objSelection.TypeParagraph()

objSelection.TypeParagraph()

objSelection.Font.Size="10"

strComputer="."

SetobjWMIService=GetObject("winmgmts:"&strComputer&"rootcimv2")

SetcolItems=objWMIService.ExecQuery_

("Select*fromWin32_NetworkAdapterConfiguration")

ForEachobjItemincolItems

objSelection.Font.Bold=True

objSelection.TypeText"ARPAlwaysSourceRoute:"

objSelection.Font.Bold=False

objSelection.TypeText""&objItem.ArpAlwaysSourceRoute

objSelection.TypeParagraph()

objSelection.Font.Bold=True

objSelection.TypeText"ARPUseEtherSNAP:"

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"DatabasePath:"

objSelection.Font.Bold=False

objSelection.TypeText""&objItem.DatabasePath

objSelection.TypeParagraph()

objSelection.Font.Bold=True

objSelection.TypeText"DeadGWDetectionEnabled:"

objSelection.Font.Bold=False

objSelection.TypeText""&objItem.DeadGWDetectEnabled

objSelection.TypeParagraph()

objSelection.Font.Bold=True

objSelection.TypeText"DefaultIPGateway:"

objSelection.Font.Bold=False

objSelection.TypeText""&objItem.DefaultIPGateway

objSelection.TypeParagraph()

objSelection.Font.Bold=True

objSelection.TypeText"DefaultTOS:"

objSelection.Font.Bold=False

objSelection.TypeText""&objItem.DefaultTOS

objSelection.TypeParagraph()

objSelection.Font.Bold=True

objSelection.TypeText"DefaultTTL:"

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:ScriptsWordtestdoc.doc")

objWord.Quit

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类