[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Defining a range in a Word Document

Posted on 2005-04-28
Medium Priority
Last Modified: 2010-04-23
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.
Question by:escheider
  • 2

Expert Comment

ID: 13888991
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?

Author Comment

ID: 13890701
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.
LVL 34

Accepted Solution

Sancler earned 2000 total points
ID: 13890895
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.


Author Comment

ID: 13908867
Thank you Sancler .. this is exactly what I needed to define the location of the cursor, even in Word 2000.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month19 days, 22 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question