word_宏示例

Posted fmgao-technology

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了word_宏示例相关的知识,希望对你有一定的参考价值。

参考: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:lili范式.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_宏示例的主要内容,如果未能解决你的问题,请参考以下文章

关于 word VBA的宏运行 输入文本的代码 急求 谢谢

12_关于flask中的宏

如何使Microsoft Word的宏生成多个文档?

Flask模板宏的概念和基本使用

宏&一个简单的宏病毒示例

word 常用宏代码