内容发布更新时间 : 2025/1/7 15:45:44星期一 下面是文章的全部内容请认真阅读。
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