Regex but maintain font formatting?
Previously I asked for help with a word VBA macro regex.
Is th开发者_StackOverflow中文版ere a way to maintain font formatting when doing this?
Not very elegant, but is this not what you want (or do you mean that you want to replace the entire contents with a single '0')?
Sub Macro1()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^$*"
.Replacement.Text = "0"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
精彩评论