使用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