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

Add a Formatted Table to a Word Document

发布时间:2007-06-15 作者: 来源:转载
DemonstrationscriptthatretrievesservicedatafromacomputerandthendisplaysthatdatainaformattedtableinMicrosoftWord.复制代码代码如下:SetobjWord=CreateObject("Word.Application")objWord.Visible=TrueSetobjDoc=objWord.Documents.Add()SetobjRan
Demonstrationscriptthatretrievesservicedatafromacomputerand
thendisplaysthatdatainaformattedtableinMicrosoftWord.
复制代码 代码如下:
SetobjWord=CreateObject("Word.Application")
objWord.Visible=True
SetobjDoc=objWord.Documents.Add()

SetobjRange=objDoc.Range()
objDoc.Tables.AddobjRange,1,3
SetobjTable=objDoc.Tables(1)

x=1

strComputer="."
SetobjWMIService=_
GetObject("winmgmts:"&strComputer&"rootcimv2")
SetcolItems=objWMIService.ExecQuery("Select*fromWin32_Service")

ForEachobjItemincolItems
Ifx>1Then
objTable.Rows.Add()
EndIf
objTable.Cell(x,1).Range.Font.Bold=True
objTable.Cell(x,1).Range.Text=objItem.Name
objTable.Cell(x,2).Range.text=objItem.DisplayName
objTable.Cell(x,3).Range.text=objItem.State
x=x+1
Next


相关推荐