Word几个实用宏解决方案

更新时间:2023-10-21 03:40:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

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

本文来源:https://www.bwwdw.com/article/wzpf.html

Top