作家
登录

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

作者: 来源:www.28hudong.com 2013-03-30 03:25:18 阅读 我要评论

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:ScriptsWordTestdoc.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 & "rootcimv2") 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:ScriptsWordtestdoc.doc") objWord.Quit

  推荐阅读

  非常不错的一个JS分页效果代码,值得研究

本来想用网上找来的分页程序,不过都得做修改,感觉麻烦了,还是自己写一个好了,以后自己用的时候修改就方便了~~大家都多动手,自己写的才是最好的,日后想干什么的,做修改也是很容易的~~顺便也扩充一下自己的代码库~~ >>>详细阅读


本文标题:用jscript实现新建和保存一个word文档

地址:http://www.17bianji.com/kaifa2/JS/30344.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)