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 & "\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
相关推荐
-
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
-
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
-
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
-
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
-
使用c#在word文档中创建表格的方法详解
复制代码 代码如下: public string CreateWordFile() { string message = ""; try { Object Nothing = System.Reflection.Missing.Value; string name = "xiehuan.doc";
随机推荐
- 用批处理删除N天前或指定日期时间(前后)创建(或修改)的文件
- SWT(JFace)体验之Slider,Scale
- Delphi实现读取系统时间与日期完整实例
- 详解Vue 2.0封装axios笔记
- 符合web标准的媒体播放器代码
- 深入领悟JavaScript中的面向对象
- 历代木马程序隐身的技术分析第1/2页
- 初步解析Java中AffineTransform类的使用
- 浅析2种JavaScript继承方式
- asp.net下检测远程URL是否存在的三种方法
- javascript 保存文件到本地实现方法
- asp 小偷采集程序原理与常用函数方法
- Android编程中Perferences的用法实例分析
- MySQL thread_stack连接线程的优化
- 微信小程序 location API接口详解及实例代码
- 百度地图API之本地搜索与范围搜索
- JQUERY对单选框(radio)操作的小例子
- 在Debian系的Linux中编译并安装ixgbe驱动的教程
- 基于linnux+phantomjs实现生成图片格式的网页快照
- c# 网址压缩简单实现短网址
