欢迎来到福编程网,本站提供各种互联网专业知识!

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

发布时间:2007-06-15 作者: 来源:转载
Demonstrationscriptthatretrievesnetworkadapterdatafromacomputer,displaysthatdatainaMicrosoftWorddocument,andthensavesthedocumentasC:\Scripts\Word\Testdoc.doc.复制代码代码如下:SetobjWord=CreateObject("Word.Application")objWord.Capti
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


相关推荐