Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba 替换范围内的多个文本_Vba_Ms Word_Word 2007 - Fatal编程技术网

Vba 替换范围内的多个文本

Vba 替换范围内的多个文本,vba,ms-word,word-2007,Vba,Ms Word,Word 2007,例如,我想替换多个文本/标点符号 ”,“带” “'s”与” ,是我下一步不需要的额外文本 Replace方法只能更改一次 是否有其他方法替换以下句子中的多个文本 “Aabar仍专注于阿布扎比在2020年世博会之前在迪拜的扩张计划” Replace与一起工作,但的仍然存在 Sub make_range_replace_string() Dim R As Range Dim F As String Do selection.Find.ClearFormatting selection

例如,我想替换多个文本/标点符号

”,“

“'s”

是我下一步不需要的额外文本

Replace
方法只能更改一次

是否有其他方法替换以下句子中的多个文本

“Aabar仍专注于阿布扎比在2020年世博会之前在迪拜的扩张计划”

Replace
一起工作,
仍然存在

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 Gleney是正确的,但只需使用“而不是”即可。 换言之;多次使用“替换”功能

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

Doug Gleney是正确的,但只需使用“而不是”即可。 换言之;多次使用“替换”功能

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

您可以嵌套
Replace
函数,如
F=Replace(Replace(R,,,,,,,,,,,,,,,)
@douglancy
Replace
一起工作,
但是
仍然存在。我应该怎么做?用所有替换词创建一个二维数组,并用上面发布的代码在列表中迭代。你可以嵌套
Replace
函数,比如
F=Replace(Replace(R,,,,,,,,,,,,,,,,,,,,,)
@douglancy
Replace
可以使用
但是
仍然存在。我该怎么办?用所有替换词创建一个二维数组,并用上面发布的代码在列表中迭代。正如您所注意到的,
附在文本后,因此
替换(F,“'s,”)
不起作用。应该有另一种方法吗?奇怪的是,我用更多的
的变体编辑了答案,因为你注意到
附在文本后,所以
替换(F,“'s,”)
不起作用。应该还有另一种方法吗?奇怪的是,我用了更多的
变体来编辑答案