Defining a range in a Word Document

Hello Experts:

I have successfully create an object to open an existing word document, setup a command bar and created buttons on the command bar that interact with the document; However, I am having one problem.  I need to determine the current location of the cursor so that I can create a range to insert some information.

I have an object called Worddoc that represents the currently opened document.  I also have an variable that is used to reference a range within that document .. wrdRange.

I'll be glad to award 1000 points to the individual that helps me solve this issue.

Thanks ...

I'm currently coding this for Word 2000.
Who is Participating?
SanclerConnect With a Mentor Commented:
I no longer have Word 2000, but in an active MSWord document in Word 2002 the position of the cursor seems to be derivable from the start and end properties of the Selection object.

I don't have a lot of experience in this area, but my best guess is that it is unikely you can get that info. I am assuming that the document object represents a word document. The cursor however, is a function of Microsoft Word.

In other words, MS Word is the editor, and it maintaines the location of the cursor. That cursor location isn't "saved" when you save the document. Close the document and open it again, the cursor goes back to the beginning.

So if your document object represents a word doc, then I don't see how it could determine where the cursor is in the editor.

Of course, I could be completely wrong... :)

Perhaps you could implement some sort of method such as having the user insert a custom tag in the Word doc, and then searching the doc to locate that tag, and go from there?
escheiderAuthor Commented:
Even if I inserted the custom tag, I'd like to do it by clicking the button on the commandbar that I have created; Therefore, I would still need to know the location of the cursor to do this.   I am using this application to build templates and the commandbar is used to complete this process.
escheiderAuthor Commented:
Thank you Sancler .. this is exactly what I needed to define the location of the cursor, even in Word 2000.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.