Word几个实用宏解决方案
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Sub 自动编号改为手动编号()
ActiveDocument.Content.ListFormat.ConvertNumbersToText
End Sub
Sub 批量去除域()
ActiveDocument.Content.Fields.Unlink
End Sub
Sub CenterPara()
'绝对居中(中国式居中)
With Selection.ParagraphFormat
.CharacterUnitFirstLineIndent = 0
.FirstLineIndent = 0
.CharacterUnitLeftIndent = 0
.LeftIndent = 0
.CharacterUnitRightIndent = 0
.RightIndent = 0
.Alignment = wdAlignParagraphCenter
End With
End Sub
Sub 选中所有的表格()
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
Sub 文本反选()
'对常规文本进行反选
Dim myRange As Range, oEditor As Editor
On Error Resume Next
If Application.Version < 11 Then
MsgBox "版本过低!"
Exit Sub
End If
If ActiveDocument.Range(ActiveDocument.Range.End - 1, _ ActiveDocument.Range.End).Font.Hidden = True Then MsgBox "文档最后的段落标记不能设置为隐藏文字" Exit Sub
End If
If ActiveDocument.Range.Font.Hidden <> False Then MsgBox "此文档有隐藏文字"
Exit Sub
End If
If ActiveDocument.ProtectionType <> wdNoProtection Then MsgBox "文档处于保护状态"
Exit Sub
End If
If Selection.Type <> wdSelectionNormal Then
MsgBox "所选内容为非常规文本"
Exit Sub
End If
Application.ScreenUpdating = False
With ActiveDocument
.Range.Font.Hidden = False
.DeleteAllEditableRanges (wdEditorEveryone)
Application.ScreenUpdating = False
.ActiveWindow.View.ShowHiddenText = True
.Content.Editors.Add wdEditorEveryone
Selection.Font.Hidden = True
GN: Set myRange = .Content
With myRange.Find
.ClearFormatting
.Font.Hidden = True
Do While .Execute = True
myRange.Select
myRange.Editors(wdEditorEveryone).Delete
myRange.Font.Hidden = False
GoTo GN
Loop
End With
.ActiveWindow.View.ShadeEditableRanges = False
.SelectAllEditableRanges (wdEditorEveryone)
.DeleteAllEditableRanges (wdEditorEveryone)
End With
Application.ScreenUpdating = True
End Sub