Demonstration script that retrieves service data from a computer and then displays that data in a formatted table in Microsoft Word
Set word = CreateObject( "Word.Application" )
word.Visible = True
Set doc = word.Documents.Add()
Set range = doc.Range()
doc.Tables.Add range, 1, 3
Set table = doc.Tables( 1 )
x = 1
sComputer = "."
Set wmiService = GetObject( "winmgmts:\\" & sComputer & "\root\cimv2" )
Set itemsColl = wmiService.ExecQuery( "Select * from Win32_Service" )
For Each item in itemsColl
If x > 1 Then
table.Rows.Add()
End If
table.Cell( x, 1 ).Range.Font.Bold = True
table.Cell( x, 1 ).Range.Text = item.Name
table.Cell( x, 2 ).Range.text = item.DisplayName
table.Cell( x, 3 ).Range.text = item.State
x = x + 1
Next
Posted in MS-Word

daniva




Recent Comments