我是靠谱客的博主 追寻冬瓜,最近开发中收集的这篇文章主要介绍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


  

最后

以上就是追寻冬瓜为你收集整理的Add a Table to a Word Document的全部内容,希望文章能够帮你解决Add a Table to a Word Document所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(87)

评论列表共有 0 条评论

立即
投稿
返回
顶部