Sub 添加表格()
'
If MsgBox("要为所有表格添加列吗?", vbYesNo + vbQuestion) = vbYes Then
For i = To ActiveDocument.Tables.Count Dim myTable As Table
Set myTable = ActiveDocument.Tables(i)
myTable.Rows.Last.Select Selection.InsertRowsBelow
Selection.Collapse Direction:=wdCollapseStart
Selection.TypeText Text:="实际结果"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="与期望结果一致"
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="测试结果"
Selection.MoveRight Unit:=wdCell
Selection.Cells.Split NumRows:=, NumColumns:=, MergeBeforeSplit:=False
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="通过"
Selection.SelectCell
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.SelectCell
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="缺陷编号"
Selection.SelectCell
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="备注"
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCharacter, Count:=, Extend:=wdExtend
Selection.Cells.Merge
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="测试人"
Selection.MoveRight Unit:=wdCell
Selection.Cells.Split NumRows:=, NumColumns:=, MergeBeforeSplit:=False
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="XXX"
Selection.SelectCell
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="测试日期"
Selection.SelectCell
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.MoveRight Unit:=wdCell
Selection.TypeText Text:="2016-4-18"
Selection.MoveLeft Unit:=wdCharacter, Count:=
Selection.MoveUp Unit:=wdLine, Count:=
Selection.TypeText Text:="无"
Selection.SelectCell
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.MoveDown Unit:=wdLine, Count:=
Selection.MoveRight Unit:=wdCharacter, Count:=
Selection.SelectCell
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter Next
MsgBox ("完成")
Else
MsgBox ("任务取消")
End If
End Sub

VBA添加表格的更多相关文章

  1. OpenXml入门----给Word文档添加表格

    下面将展示如何使用Openxm向Word添加表格. 代码中表头和数据我用的同一个TableRow来添加,其实可以通过TableHeader来,其实都一样.后面教程我会给出如何设置单元格样式.表头那一行 ...

  2. jquery 动态添加表格行

    jquery 动态添加表格行 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <h ...

  3. C# 在Word中添加表格的方法

    表格是组织整理数据的一种重要手段,应在生活中的方方面面.在Word文档中将繁杂的文字表述内容表格化,能快速.直接地获取关键内容信息.那么,通过C#,我们也可以在Word文档中添加表格,这里将介绍两种不 ...

  4. JQuery动态添加表格,然后动态删除不成功问题

    背景: 自己做了一个测试网页,想动态添加表格,然后删除,按照网上的教程写完,发现点击"删除参数"按钮没用 源码: function addtr() { var trinfo = & ...

  5. Java 在PDF中添加表格

    本文将介绍通过Java编程在PDF文档中添加表格的方法.添加表格时,可设置表格边框.单元格对齐方式.单元格背景色.单元格合并.插入图片.设置行高.列宽.字体.字号等. 使用工具:Free Spire. ...

  6. 从头开始一步一步实现EF6+Autofac+MVC5+Bootstarp极简前后台ajax表格展示及分页(二)前端修改、添加表格行点击弹出模态框

    在前一篇中,由于不懂jquery,前端做的太差了,今天做稍做修改,增加一个跳转到指定页面功能,表格行点击样式变化.并且在表格中加入bootstarp的按钮组,按钮点击后弹出模态框,须修改common, ...

  7. VBA删除表格最后一行

    Sub 删除最后一行() If MsgBox("要为所有表格添加列吗?", vbYesNo + vbQuestion) = vbYes Then To ActiveDocument ...

  8. js动态向页面中添加表格

    我们在实际开发中经常会想要实现如下情况: 点击某个按钮,然后动态的网页面里面添加一个表格或者一行,这个更加灵活方便.但是实现起来肯定不能像在页面里面直接写标签来的容易,以下是我项目中的代码,拿过来分享 ...

  9. js动态添加-表格逐行添加、删除、遍历取值

    关于js对表格进行逐行添加,今天抽空整理了一下:新建一个html文件(没有编辑器的可以新建一个demo.txt文件,然后改后缀名为demo.html),把下面代码全部贴进去即可.功能包括:表格添加一行 ...

随机推荐

  1. bootstrap-按钮组、字体图标

    字体图标: <div class="container"> <div class="row"> <span class=" ...

  2. 安装ipython import path error

    sudo pip install ipython --upgrade # 升级 版本兼容性问题,升级到最新版本的ipython 后,会报错 from pickleshare import Pickle ...

  3. ORM框架:EF与NHibernate了解

    在.Net Framework SP1微软包含一个实体框架(Entity Framework),此框架可以理解成微软的一个ORM产品.用于支持开发人员通过对概念性应用程序模型编程(而不是直接对关系存储 ...

  4. Mingyang.net:注解配置Hibernate时报错Unknown Entity

    注解配置时报错:org.hibernate.MappingException: Unknown entity: net.mingyang.cms.bean.User org.hibernate.Map ...

  5. fatal: Not a git repository (or any of the parent directories): .git

    $ git remote add origin https://github.com/heyuanchao/YouxibiClient.gitfatal: Not a git repository ( ...

  6. OLAP如何实现数据的聚合计算-分析过程

  7. flexgrid的应用

    第一.导入必须的CSS与JS: <link rel="stylesheet" type="text/css" href="css/flexigr ...

  8. Android——KEYCODE列表

    电话键 键名 描述 键值   KEYCODE_CALL 拨号键 5 KEYCODE_ENDCALL 挂机键 6 KEYCODE_HOME 按键Home 3 KEYCODE_MENU 菜单键 82 KE ...

  9. 一个简单的AJAX实例

    创建一个简单的XMLHttpRequest,从一个TXT文件中返回数据. 来源于菜鸟教程 <!DOCTYPE html><html><head><meta c ...

  10. windows server 2008 IP安全策略关闭端口,禁止ping,修改远程连接3389端口,开放指定端口

    windows server 2008 IP安全策略关闭端口:      Tomcat服务访问不了情况解决.    Windows默认情况下有很多端口是开放的,在你上网的时候,网络病毒和黑客可以通过这 ...