Demonstration script that retrieves service data from a computer, displays that data in a table in Microsoft Word, then formats the data by using a predefined Microsoft Word style
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 )
table.Range.Font.Size = 10
table.Range.Style = "Table Contemporary"
x = 2
table.Cell( x, 1 ).Range.Text = "Process Name"
table.Cell( x, 2 ).Range.text = "Process ID"
table.Cell( x, 3 ).Range.text = "Virtual Size"
sComputer = "."
Set wmiService = GetObject( "winmgmts:\\" & sComputer & "\root\cimv2" )
Set itemsColl = wmiService.ExecQuery( "Select * from Win32_Process" )
For Each item in itemsColl
If x > 1 Then
table.Rows.Add()
End If
table.Cell( x, 1 ).Range.Text = item.Name
table.Cell( x, 2 ).Range.text = item.ProcessId
table.Cell( x, 3 ).Range.text = item.VirtualSize
x = x + 1
Next
Posted in MS-Word

daniva




Recent Comments