Add a Formatted Table to a Word Document
Demonstration script that retrieves service data from a computer and
then displays that data in a formatted table 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.Font.Bold = True
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 Formatted Table to a Word Document
Demonstration script that retrieves service data from a computer and then displays that data in a formatted table in Microsoft Word. 复制代码 代码如下: Set objWord = CreateObject("Word.Application") objWord.Visible = True Set objDoc = objWord.Documents
-
Add Formatted Text to a Word Document
Demonstration script that displays formatted data in a Microsoft Word document. 复制代码 代码如下: Set objWord = CreateObject("Word.Application") objWord.Visible = True Set objDoc = objWord.Documents.Add() Set objSelection = objWord.Selection objSelect
-
Add a Picture to a Microsoft Word Document
Demonstration script that adds a picture (C:\Scripts\Logo.jog) to a Microsoft Word document 复制代码 代码如下: Set objWord = CreateObject("Word.Application") objWord.Visible = True Set objDoc = objWord.Documents.Add() Set objSelection = objWord.Selectio
-
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
-
Open and Print a Word Document
Demonstration script that opens and prints and existing Microsoft Word document. 复制代码 代码如下: Set objWord = CreateObject("Word.Application") Set objDoc = objWord.Documents.Open("c:\scripts\inventory.doc") objDoc.PrintOut() objWord.Quit
-
JavaScript将Web页面内容导出到Word及Excel的方法
本文实例讲述了JavaScript将Web页面内容导出到Word及Excel的方法.分享给大家供大家参考.具体实现方法如下: <HTML> <HEAD> <title>WEB页面导出为EXCEL文档的方法 </title> </HEAD> <body> <BR> <table id = "PrintA" width="100%" border="1" cel
-
asp.net中如何批量导出access某表内容到word文档
下面通过图文并茂的方式给大家介绍asp.net中批量导出access某表内容到word文档的方法,具体详情如下: 一.需求: 需要将表中每一条记录中的某些内容导出在一个word文档中,并将这些文档保存在指定文件夹目录下 二.界面,简单设计如下: 三.添加office相关引用 添加后可在解决方案资源管理器中看到: 四.添加form1中的引用 using System.Data.OleDb; using System.Data.SqlClient; using System.IO; using Mi
-
C# WORD操作实现代码
1.先通过程序生成报表样式的HTML页面,然后修改HTML页面的后缀名为DOC. 2.定制WORD文档的模板文件,在C#中操作WORD模板,生成新的WORD文档. 第一方案简单,只需要改动文件的扩展名就行了,但是也存在了一些问题,譬如生成的WORD文档样式的丢失.这样对于客户来说可能是一个无法通过的方案.第二方案比较复杂,需要调用OFFICE的WORD组件通过C#来操作WORD,进而生成WORD.此方法类似于我们在c#中的后台拼接数据.虽然麻烦,但是能够灵活定制,只不过是操作WORD对象而已.
-
C# Word 类库的深入理解
代码如下所示: 复制代码 代码如下: using System;using System.Collections.Generic;using System.Text;using Microsoft.Office.Interop.Word;using System.IO;using System.Web;using System.Data;using System.Reflection;using Microsoft.Win32;using System.Text.RegularExpressio
-
比较全的一个C#操作word文档示例
最近两天研究了一下如何使用VS2008(C#语言)输出Word文档.以下是几点总结: 1.非常简单. 2.开发及运行环境要求.操作系统为:WindowsXP(安装.net framework2.0)/Vista/Win7:在操作系统必须安装Word2003完全安装版.这里必须要强调是Word2003完全安装版,因为软件开发及运行都需要一个com组件:Microsoft word 11.0 Object Library.如果不是Word2003完全安装版,可以下载这个com组件,并手动的安装这个c
随机推荐
- PHP跳转页面的几种实现方法详解
- javascript动态添加checkbox复选框的方法
- js form action动态修改方法
- 详解使用zxing库生成QR-Code二维码
- IOS身份证识别(OCR源码)详解及实例代码
- JavaScript NaN和Infinity特殊值 [译]
- javascript 获取多条数据(模拟ajax获取数据)
- asp.net 用户在线退出更新实现代码
- 在Python程序中操作文件之flush()方法的使用教程
- jQuery+JSON实现AJAX二级联动实例分析
- php绘制一个扇形的方法
- 使用aspose.word 第三方的插件实现导出word
- 酷炫!趣味十足的Linux命令
- 自动化测试读写64位操作系统的注册表
- Android编程使用Intent传递图片的方法详解
- C++11的for循环,以及范围Range类的简单实现
- C#读写INI文件的方法
- 简单实现java数独游戏
- php curl批处理实现可控并发异步操作示例
- Go语言字符串高效拼接的实现
