【发布时间】:2021-04-07 15:12:15
【问题描述】:
我使用以下代码来删除格式。不知何故,它不起作用。
Sub rep_test()
Dim TempS As String
TempS = Replace_chars("]", "]")
End Sub
Function Replace_chars(search_txt As String, replace_txt As String)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = search_txt
.Replacement.Text = replace_txt
.Replacement.Font.Bold = False
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
End With
Selection.Find.Execute Replace:=wdReplaceAll, Format:=False
End Function
文本示例:
Aaa [BBB] CC [DDD]
知道为什么吗?
【问题讨论】:
标签: vba ms-word formatting format