所以我有一组代码可以选择要隐藏的特定范围的文本,我需要有一个宏来选择那些隐藏的文本并取消隐藏它们。但是,我不知道如何在不先显示这些隐藏文本的情况下选择这些隐藏文本。有没有办法在不显示隐藏文本时选择它们。我正在尝试创建一个动态模板,如果选择某些条件,则只会显示某些文本。到目前为止,这是我隐藏隐藏文字的代码。
Sub Macro2()
'
' Macro2 Macro
'
'
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveUp Unit:=wdParagraph, Count:=4, Extend:=wdExtend
With Selection.Font
.NameFarEast = "+Body Asian"
.NameAscii = "+Body"
.NameOther = "+Body"
.Name = "+Body"
.Size = 11
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone
.DisableCharacterSpaceGrid = False
.EmphasisMark = wdEmphasisMarkNone
.Ligatures = wdLigaturesNone
.NumberSpacing = wdNumberSpacingDefault
.NumberForm = wdNumberFormDefault
.StylisticSet = wdStylisticSetDefault
.ContextualAlternates = 0
End With
End Sub
答案 0 :(得分:1)
隐藏文字必须在屏幕上可见,才能被选中。所以你需要在代码中使用它。你不需要隐藏它们;
ActiveDocument.ActiveWindow.View.ShowHiddenText = True
如果您希望用户在运行时看不到文本,则可以执行此操作。但是,它没有经过测试;
Application.ScreenUpdating = False
请记住在代码末尾重新打开它;
Application.ScreenUpdating = True