我需要搜索并将<tn>替换为<NEST>,但只搜索在每一段/行中出现两次以上的那些:即Flintstones<tn>Fred<tn>Wilma (保持本段不变)
Flintstones<tn>Fred<tn>Wilma<tn>Pebbles<tn>BamBam<tn>Dino (更改为) Flintstones<NEST>Fred<NEST>Wilma<NEST>Pebbles<NEST>BamBam<NEST>Dino
我试过了,但我的知识非常有限。提前感谢您可能给予的帮助。
发布于 2015-06-10 18:07:03
这是一个小的宏,它将为您完成这项工作。快乐的VBA :-)
Public Sub ReplaceTN()
**Dim J As Integer
For J = 1 To ActiveDocument.Paragraphs.Count**
ActiveDocument.Paragraphs(J).Range.Select
If UBound(Split(Selection.Text, "<tn>")) > 2 Then
With Selection.Find
.Text = "<tn>"
.Replacement.Text = "<NEST>"
.Forward = True
.Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End If
**Next J** End Subhttps://stackoverflow.com/questions/30752194
复制相似问题