Add a Table to a Word Document_javascript技巧
程序员文章站
2022-05-01 09:10:24
...
Demonstration script that retrieves service information from a
computer and then displays that information in tabular format in Microsoft Word.
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objRange = objDoc.Range()
objDoc.Tables.Add objRange,1,3
Set objTable = objDoc.Tables(1)
x=1
strComputer = "."
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objItem in colItems
If x > 1 Then
objTable.Rows.Add()
End If
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
computer and then displays that information in tabular format in Microsoft Word.
复制代码 代码如下:
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add()
Set objRange = objDoc.Range()
objDoc.Tables.Add objRange,1,3
Set objTable = objDoc.Tables(1)
x=1
strComputer = "."
Set objWMIService = _
GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objItem in colItems
If x > 1 Then
objTable.Rows.Add()
End If
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
上一篇: JQuery学习总结
下一篇: js实现斐波那契数列
推荐阅读
-
Add a Picture to a Microsoft Word Document_javascript技巧
-
Add a Picture to a Microsoft Word Document_javascript技巧
-
Add a Table to a Word Document_javascript技巧
-
Open and Print a Word Document_javascript技巧
-
Open and Print a Word Document_javascript技巧
-
Add Formatted Text to a Word Document_javascript技巧
-
Add a Table to a Word Document_javascript技巧
-
Add a Formatted Table to a Word Document_javascript技巧
-
Add Formatted Text to a Word Document_javascript技巧
-
Add a Formatted Table to a Word Document_javascript技巧