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