Word:利用宏批量選中Word表格VBA代碼
Sub SelectAllTables()
? ? Dim tempTable As Table
? ??
? ? Application.ScreenUpdating = False
? ??
? ? '判斷文檔是否被保護
? ? If ActiveDocument.ProtectionType = wdAllowOnlyFormFields Then
? ? ? ? MsgBox "文檔已保護,此時不能選中多個表格!"
? ? ? ? Exit Sub
? ? End If
? ? '刪除所有可編輯的區(qū)域
? ? ActiveDocument.DeleteAllEditableRanges wdEditorEveryone
? ? '添加可編輯區(qū)域
? ? For Each tempTable In ActiveDocument.Tables
? ? ? ? tempTable.Range.Editors.Add wdEditorEveryone
? ? Next
? ? '選中所有可編輯區(qū)域
? ? ActiveDocument.SelectAllEditableRanges wdEditorEveryone
? ? '刪除所有可編輯的區(qū)域
? ? ActiveDocument.DeleteAllEditableRanges wdEditorEveryone
? ??
? ? Application.ScreenUpdating = True
? ??
End Sub
標簽: