zoukankan      html  css  js  c++  java
  • VBA添加表格

    Sub 添加表格()
    '
    If MsgBox("要为所有表格添加列吗?", vbYesNo + vbQuestion) = vbYes Then
    For i = 1 To ActiveDocument.Tables.Count
    
    Dim myTable As Table
    Set myTable = ActiveDocument.Tables(i)
    myTable.Rows.Last.Select
    
    Selection.InsertRowsBelow 1
    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:=1, NumColumns:=3, 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:=3, Extend:=wdExtend
    Selection.Cells.Merge
    Selection.MoveRight Unit:=wdCell
    Selection.TypeText Text:="测试人"
    Selection.MoveRight Unit:=wdCell
    Selection.Cells.Split NumRows:=1, NumColumns:=3, 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:=1
    Selection.MoveUp Unit:=wdLine, Count:=1
    Selection.TypeText Text:=""
    Selection.SelectCell
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
    Selection.MoveDown Unit:=wdLine, Count:=1
    Selection.MoveRight Unit:=wdCharacter, Count:=5
    Selection.SelectCell
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
    
    Next
    MsgBox ("完成")
    Else
    MsgBox ("任务取消")
    End If
    End Sub
    
     
  • 相关阅读:
    Sliverlight之 矢量绘图
    Silverlight之 xaml布局
    七天学会ASP.NET MVC(七)——创建单页应用
    MVC视图之间调用方法总结
    C#取得程序的根目录以及判断文件是否存在
    七天学会ASP.NET MVC (六)——线程问题、异常处理、自定义URL
    [C#] .NET4.0中使用4.5中的 async/await 功能实现异步
    C#中StreamReader读取中文文本出现乱码的解决方法
    七天学会ASP.NET MVC (五)——Layout页面使用和用户角色管理
    常用正则表达式
  • 原文地址:https://www.cnblogs.com/zjwia/p/5403429.html
Copyright © 2011-2022 走看看