5,172
社区成员




Sub replece()
'
'此函数首先输入您要替换的文本,然后输入你要替换成的文本,最后执行替换并且将替换的文本置成蓝色
Dim iResult1 As String, iResult2 As String
iResult1 = InputBox("请输入你需替换的文本")
iResult2 = InputBox("请输入你要替换成的文本")
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlue
With Selection.Find
.Text = iResult1
.Replacement.Text = iResult2
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
msgbox “已成功替换,并将替换文本置成蓝色!!”
End Sub
Sub show_cur_pos()
Dim rng As Range
Dim pos As Long
Set rng = Selection.Range
pos = rng.Start
MsgBox pos
End Sub