Create Range from current cursor position Word 2010 VBA

前端 未结 1 1391
耶瑟儿~
耶瑟儿~ 2021-01-01 02:40

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 posi

相关标签:
1条回答
  • 2021-01-01 03:33
    • Selection is the current position in the document.
    • Selection.Range is the Range object of the current Selection.
    • Range.Start is the start position of a Range 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"
    
    0 讨论(0)
提交回复
热议问题