码迷,mamicode.com
首页 > 其他好文 > 详细

word_宏示例

时间:2019-01-22 17:25:34      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:http   art   word   ati   ocx   enter   nbsp   string   html   

参考:https://jingyan.baidu.com/article/870c6fc3326588b03fe4beeb.html

内容自适应

Application.Browser.Target = wdBrowseTable

  For i = 1 To ActiveDocument.Tables.Count

  ActiveDocument.Tables(i).AutoFitBehavior (wdAutoFitContent) ‘根据内容自动调整表格

  ActiveDocument.Tables(i).AutoFitBehavior (wdAutoFitWindow) ‘根据窗口自动调整表格

  ActiveDocument.Tables(i).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter ‘水平居中

  ActiveDocument.Tables(i).Range.ParagraphFormat.Alignment = wdCellAlignVerticalCenter ‘垂直居中

  Next i

 表格修改

Sub www()
‘
‘ www 宏
‘
‘
   Dim oDoc As Document
   Dim oTable As Table
   Dim cellLoop As Cell
   Set oDoc = Documents.Open("F:\li\li\范式.docx")
   Dim RowNum As Long, ColumnNum As Long, i As Long, oString As String
   For Each oTable In oDoc.Tables
       RowNum = oTable.Rows.Count
       Column = oTable.Columns.Count
       If Column >= 5 Then
            For i = 1 To RowNum
                    oString = oTable.Cell(i, 4).Range.Text
                    If InStr(1, oString, "日期") = 1 Then
                         oTable.Cell(i, 5).Select
                         Selection.Delete
                    End If
             Next
        End If
   Next
   MsgBox "Finished!"
End Sub

 

word_宏示例

标签:http   art   word   ati   ocx   enter   nbsp   string   html   

原文地址:https://www.cnblogs.com/fmgao-technology/p/10304564.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!