Add a Table to a Word Document

xiaolong016

xiaolong016

2016-02-19 09:24

给自己一点时间接受自己,爱自己,趁着下午茶的时间来学习图老师推荐的Add a Table to a Word Document,过去的都会过去,迎接崭新的开始,释放更美好的自己。
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 & "rootcimv2")
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


  
展开更多 50%)
分享

猜你喜欢

Add a Table to a Word Document

Web开发
Add a Table to a Word Document

Add a Formatted Table to a Word Document

Web开发
Add a Formatted Table to a Word Document

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Add Formatted Text to a Word Document

Web开发
Add Formatted Text to a Word Document

Add a Picture to a Microsoft Word Document

Web开发
Add a Picture to a Microsoft Word Document

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

Open and Print a Word Document

Web开发
Open and Print a Word Document

document.open() 与 document.write()的区别

Web开发
document.open() 与 document.write()的区别

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

类之Prototype.js学习

类之Prototype.js学习

android GridView多选效果的实例代码

android GridView多选效果的实例代码
下拉加载更多内容 ↓