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

时间:2021-05-18

Demonstrationscriptthatretrievesnetworkadapterdatafromacomputer,
displaysthatdatainaMicrosoftWorddocument,andthensavesthe
documentasC:\Scripts\Word\Testdoc.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&"\root\cimv2")
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:\Scripts\Word\testdoc.doc")
objWord.Quit




声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章