替换范围内的多个文本
Replace multiple text in Range
我想替换多个文本/标点符号,例如
","
与 " "
"'s"
与 " "
,
's
是我下一步不需要的额外文本。
Replace
方法只能改变一次
是否有任何其他方法可以替换以下句子中的多个文本?
"Aabar remains focused on Abu Dhabi’s plans expansion, In Dubai ahead of Expo 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
Doug Glancey 是正确的,只是使用'而不是'。
换一种说法;多次使用替换功能。
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
我想替换多个文本/标点符号,例如
","
与 " "
"'s"
与 " "
,
's
是我下一步不需要的额外文本。
Replace
方法只能改变一次
是否有任何其他方法可以替换以下句子中的多个文本?
"Aabar remains focused on Abu Dhabi’s plans expansion, In Dubai ahead of Expo 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
Doug Glancey 是正确的,只是使用'而不是'。 换一种说法;多次使用替换功能。
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