格式从字符或单词到行末尾的文本
下面的代码找到文本“ //”,并用绿色格式化整个线。
我正在尝试对其进行修改,以便它仅从文本“ //”到线的末尾进行格式。 ”
包括
(
“
//
Sub FindWord_and_ChangeColor()
Dim LastRow, i As Long
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Text = "//"
.Execute
End With
Do While Selection.Find.Found
Selection.Expand Unit:=wdSentence
Selection.Font.Color = RGB(107, 187, 117)
Selection.Collapse Direction:=wdCollapseEnd
Selection.Find.Execute
Loop
End Sub
。查看我是否可以在自动生成的代码中找到解决方案。但是,我感谢任何可以帮助我的人。
The code below finds the text "//" and formats the entire line with green color.
I'm trying to modify it so that it's only formatted from the text "//" to the end of the line. (including "//")
So instead of this result:
example text //color changed
I aim to achieve this:
example text //color changed
Sub FindWord_and_ChangeColor()
Dim LastRow, i As Long
Selection.HomeKey Unit:=wdStory
With Selection.Find
.ClearFormatting
.Forward = True
.Wrap = wdFindContinue
.Text = "//"
.Execute
End With
Do While Selection.Find.Found
Selection.Expand Unit:=wdSentence
Selection.Font.Color = RGB(107, 187, 117)
Selection.Collapse Direction:=wdCollapseEnd
Selection.Find.Execute
Loop
End Sub
I'm recording macros to see if I can find a solution in the auto-generated code. But I thank in advance to anyone who can help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更改
选择。expand单元:= wdsentence
to
selection.moveend单位:= wdsentence,count:= 1
Change
Selection.Expand Unit:=wdSentence
to
Selection.MoveEnd Unit:=wdSentence, Count:=1