[英]How to Run VBA Script in MS-Word From Where the Cursor Is?
I have the following 我有以下
Sub FormatOMaths()
Dim formula As OMath
For Each formula In ActiveDocument.OMaths
formula.Range.Font.TextColor = RGB(255, 0, 0)
Next
End Sub
This always executes starting from the beginning of the document. 这总是从文档的开头开始执行。 How can I modify the script to run from where my cursor is all the way down to the end of the document? 如何修改脚本,使其从光标一直一直到文档末尾运行? Thanks, 谢谢,
I wouldn't call my variable Formula
because that is a word Excel uses itself. 我不会调用我的变量Formula
因为Excel本身就是一个单词。 You might explore whether Excel will know what you mean and use your meaning instead of its own. 您可能会探索Excel是否会了解您的意思并使用您的意思而不是它的意思。 As for myself, I don't argue with Excel :-) 至于我自己,我不反对Excel :-)
Dim Frm As OMath
For Each Frm In ActiveDocument.OMaths
With Frm.Range
If .Start >= Selection.OMaths(1).Range.Start Then
.Font.TextColor = RGB(255, 0, 0)
End If
End With
Next
In case you do wish to argue: Select any variable's name in your code and press F1. 如果您确实想争论:在代码中选择任何变量的名称,然后按F1。 You will be informed what Excel needs the same word for, if it uses the same word. 如果使用相同的单词,则将通知您Excel需要使用哪个单词。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.