新建宏(宏既代码)
- alt +F11
- 选择声明(会跳出来一空行)
- 粘贴代码
运行宏(有时候已经完成但未显示,比如全选表格,结果没有高亮显示,右键以后就可以高亮了
- 在右边选择需要的宏 点运行
- 点回word编辑即可
选择所有的表格 selectAllTables
'**************************************
' 函数名: 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
版本:1 ,时间:2023/04/21/2:49