极端VBA菜鸟在这里。我正在尝试编写一个宏,该宏搜索每个选项卡及其后的字母,并用选项卡和大写字母替换它。
我已经在附近的互联网文章中找到了以下内容,但是我不确定如何正确编写Replacement.Text行。预先感谢。
Sub Capitaliser()
With Selection.Find
Text = "^t?"
Replacement.Text = UCase(Text)
Forward = True
Wrap = wdFindContinue
Format = False
MatchCase = False
MatchWholeWord = False
MatchWildcards = True
MatchSoundsLike = False
MatchAllWordForms = False
Execute Replace:=wdReplaceAll
End With
End Sub
答案 0 :(得分:0)
尝试:
Sub Demo()
Application.ScreenUpdating = False
With ActiveDocument.Range
With .Find
.ClearFormatting
.Replacement.ClearFormatting
.Text = "^t[a-z]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = True
.Execute
End With
Do While .Find.Found
.Text = UCase(.Text)
.Collapse wdCollapseEnd
.Find.Execute
Loop
End With
Application.ScreenUpdating = True
End Sub