我想替换多个文本/标点符号,例如
带有","
的 " "
带有"'s"
" "
,
's
是额外的文字,我下一步不需要。
Replace
方法只能改变一次
有没有其他方法可以替换以下句子中的多个文字?
“Aabar仍然专注于阿布扎比的计划扩张,在2020年世博会之前的迪拜”
Replace
适用于,
,但's
仍然存在。
Sub make_range_replace_string()
Dim R As Range
Dim F As String
Do
selection.Find.ClearFormatting
selection.Find.Font.Bold = True
With selection.Find
.Forward = True
.Wrap = wdFindStop
End With
selection.Find.Execute
If selection.Find.Found Then
Set R = ActiveDocument.Range(selection.Range.Start, selection.Range.End)
F = Replace(R, ",", "")
MsgBox F
Else
Exit Do
End If
Loop
End Sub
答案 0 :(得分:2)
Dim F As String
F = "Aabar remains focused on Abu Dhabi’s plans expansion, In Dubai ahead of Expo 2020"
F = Replace(F, ",", " ")
F = Replace(F, "`s", " ")
F = Replace(F, "’s", " ")
F = Replace(F, "'s", " ")
F = Replace(F, Chr(39) & "s", " ")
F = Replace(F, Chr(96) & "s", " ")
MsgBox F