Word index at current cursor location
"Ashish Sharma" wrote:
Hi
I need to get the word index where the cursor is currently positioned
for example
if i have 3-7 sentence in my document
this is line one
cursor is at XXX word
this is line three and cursor is at XXX in above line
how shd i get
cursor location is at sentenc 2 and word 4
Use the Word Count Toolbar.
Tools Word Count... Show Toolbar
Place your cursor where you need the count.
Do CTRL-SHIFT-Home key
Select "Words" in the Word Count toolbar dropdown.
Word will give you the number of words in the selection, since your
selection ends with your target word, the total is the index you seek. There
is no "Sentence" in that dropdown. If all your paragraphs are one sentence
long, you can use the paragraph count (Or line count?), but add one because
the current paragraph is not counted unless its ΒΆ is part of the selection.
If you need a "real" sentence count, you will need VBA for that (I write
"real" because a sentence to Word maybe different from your concept of a
sentence...)
|