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

使用word中的宏实现选中指定类型表格,并且批量修改样式结构

时间:2015-01-11 11:03:44      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:

使用word中的宏实现选中指定类型表格,并且批量修改样式结构

Sub SelectAllTables()
'
' SelectAllTables 宏 选中所有表格
'
'
    Dim tempTable As Table

    Application.ScreenUpdating = False
    '判断文档是否被保护
    If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
        MsgBox "文档已保护,此时不能选中多个表格!"
        Exit Sub
    End If
    '删除所有可编辑的区域
    ActiveDocument.DeleteAllEditableRanges wdEditorEveryone
    '添加可编辑区域
    For Each tempTable In ActiveDocument.Tables
        With tempTable.Columns(1).Cells(1).Range.Find
         .Text = "名称"
         .Forward = True
         .Execute
            If .Found = True Then
                'MsgBox "找到类容"
                tempTable.Range.Editors.Add wdEditorEveryone
            End If
        End With
    Next
    '选中所有可编辑区域
    ActiveDocument.SelectAllEditableRanges wdEditorEveryone
    '删除所有可编辑的区域
    ActiveDocument.DeleteAllEditableRanges wdEditorEveryone
    
    Application.ScreenUpdating = True
    
    'For i = 1 To ActiveDocument.Tables.Count
    '    ActiveDocument.Tables(i).Style = "我的格式"
    'Next
    
End Sub





使用word中的宏实现选中指定类型表格,并且批量修改样式结构

标签:

原文地址:http://blog.csdn.net/z249683156/article/details/42607961

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