Discussion:
Get word from word doc on mouse right click
(too old to reply)
Kaustav
2006-09-27 04:33:03 UTC
Permalink
Hi,

How can I get the word in a MS Word document when we right click the mouse
on it or when the cursor is at the word's end. I am not selecting the word
out here.

It is like similar to what MS Word offers when we right click any word and
select "Lookup" from the context menu or use "Spell Check" for it.
Jezebel
2006-09-27 05:24:45 UTC
Permalink
Sel.Words(1)
Post by Kaustav
Hi,
How can I get the word in a MS Word document when we right click the mouse
on it or when the cursor is at the word's end. I am not selecting the word
out here.
It is like similar to what MS Word offers when we right click any word and
select "Lookup" from the context menu or use "Spell Check" for it.
Kaustav
2006-09-27 07:48:02 UTC
Permalink
Hi Jezebel,

will this be applicable only if I have selected some text. My scenario is
that I have a sentence like - "This is brown crow" and my cursor is at the
end of the word crow. Now if I right click at that position, how do I get the
word "crow" or if I place the mouse between the letters "r" and "o" of the
word "crow" and then do a right click, how do I still manage to retrieve the
word "crow".

Word is able to do this. What I would like to know is how it does this? What
does it expose for this functionality?

Thanks.
Post by Jezebel
Sel.Words(1)
Post by Kaustav
Hi,
How can I get the word in a MS Word document when we right click the mouse
on it or when the cursor is at the word's end. I am not selecting the word
out here.
It is like similar to what MS Word offers when we right click any word and
select "Lookup" from the context menu or use "Spell Check" for it.
Jezebel
2006-09-27 07:59:45 UTC
Permalink
Why not try it, rather than guessing?

The code I gave you will select the word containing the selection, even if
the selection is a single point. So if your cursor is within the word crow
(eg between the letters "r" and "o") sel.Words(1) will return "crow". If
your cursor is not within a word then you have to do a little more work,
extending the range either forward or backward: which direction depends on
the logic of what you're doing.
Post by Kaustav
Hi Jezebel,
will this be applicable only if I have selected some text. My scenario is
that I have a sentence like - "This is brown crow" and my cursor is at the
end of the word crow. Now if I right click at that position, how do I get the
word "crow" or if I place the mouse between the letters "r" and "o" of the
word "crow" and then do a right click, how do I still manage to retrieve the
word "crow".
Word is able to do this. What I would like to know is how it does this? What
does it expose for this functionality?
Thanks.
Post by Jezebel
Sel.Words(1)
Post by Kaustav
Hi,
How can I get the word in a MS Word document when we right click the mouse
on it or when the cursor is at the word's end. I am not selecting the word
out here.
It is like similar to what MS Word offers when we right click any word and
select "Lookup" from the context menu or use "Spell Check" for it.
Klaus Linke
2006-09-30 02:16:02 UTC
Permalink
And regarding the right-click: Put the macro on the context menu for "Text"
(and "Headings" and maybe a few more, like those for tables...), manually
from "Tools > Customize", or through VBA.

Klaus

Loading...