从当前光标位置创建范围 Word 2010 VBA [英] Create Range from current cursor position Word 2010 VBA
本文介绍了从当前光标位置创建范围 Word 2010 VBA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有用户表单的 .docm
文档.在用户表单上,我有一个按钮需要在文档中最后一个已知的光标位置插入一些东西(一些文本,对于初学者).为此,我想创建一个范围.
I have a .docm
document with a user form. On the user form I have a button that needs to insert something (some text, for starter) at the last known cursor position in the document. For this, I want to create a range.
如何获得此范围的起始位置?
How can I get the starting position for this range?
推荐答案
Selection
是文档中的当前位置.Selection.Range
是当前Selection
的Range对象.Range.Start
是Range
对象的起始位置(返回或设置一个 Long).Selection
is the current position in the document.Selection.Range
is the Range object of the currentSelection
.Range.Start
is the start position of aRange
object (returns or sets a Long).
如果您将这三个组合在一起,您将获得光标位置(如果您选择了文本,则为选择的开始):
If you combine those three you get the cursor position (or the start of the selection if you have text selected):
Selection.Range.Start
如果您只想在光标位置输入文本,请执行以下操作:
If you only want to enter text att the cursor position the following will do:
Selection.TypeText "Test"
这篇关于从当前光标位置创建范围 Word 2010 VBA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文