您好,欢迎访问一九零五行业门户网

Add a Table to a Word Document_javascript技巧

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
其它类似信息

推荐信息