Create Range from current cursor position Word 2010 VBA

21,587
  • 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"
Share:
21,587
Silviu Preda
Author by

Silviu Preda

Hands-on, highly adaptable and ambitious Software Engineer with extensive experience in C#, ASP.NET, focused on enterprise software architecture, I have recently discovered a passion for leading and guiding others into reaching their full potential. I envision myself as a source of both technical and non-technical information for younger, less experienced, but smart, reactive and highly motivated developers

Updated on November 17, 2020

Comments

  • Silviu Preda
    Silviu Preda over 3 years

    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?