MS Word 2003

A

Ashok Dwivedi

Hi everyone!

For one of my programms, I want to find the 'index of selected word' in the
document which will then be passed to the function below:
ActiveDocument.Words(index)

Please help!
 
A

Ashok Dwivedi

Thanks Helmut for the reply and it worked. This is exactly what I already have.
The problem is, I am using a big for loop, where the index info is required
and
setting the range each time you loop makes the program work really slow. Is
there another way of getting 'index' without having to set the range?
 
H

Helmut Weber

Hi Ashok,

The problem is, I am using a big for loop,
where the index info is required and
setting the range each time you loop
makes the program work really slow.
Is there another way of getting 'index'
without having to set the range?

in principle, I don't think so.
Though setting a range in each iteration
of a loop isn't necessary. Maybe just moving
the range's end might be a bit faster.

Hard to give any more specific advice
whithout knowing what exactly you are doing.

One could think of getting just the first word's
index and incremeting it according to the distance
in words until the next word is found.

But that is mere speculation.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

Tony Jollans

Elements from the Words Collection are Ranges.

ActiveDocument.Words(234) is a Range with, perhaps, Start = 1234 and End =
1239

ActiveDocument.Range(1234,1239) is *exactly* the same Range.

The only reason for needing the Index is to pass it a process (or a person)
outside the VBA environment. What process do you have that requires it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top