选择WORD文档中的所有表格宏代码

主要是把 WORD 文档中的所有表格选取上,以便 单独 对文档中的所有表格进行整体编辑,宏代码如下:

'**************************************
'函数名SelectAllTables
'  :主要是把WORD文档中的所有表格选取上,以便单独对文档中的所有表格进行整体编辑。

'**************************************

Sub 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

        tempTable.Range.Editors.Add wdEditorEveryone

    Next

    '选中所有可编辑区域

    ActiveDocument.SelectAllEditableRanges wdEditorEveryone

    '删除所有可编辑的区域

    ActiveDocument.DeleteAllEditableRanges wdEditorEveryone

    Application.ScreenUpdating = True   

End Sub

 



版权声明:本文为miaozk2006原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。