Detecting characters added or deleted in word by front end VB6

R

raviki

I am writing a transliteration program in Visual Basic 6. It automatically transliterates characters typed in word to any of the Indian languages. For this the VB6 front end should know the characters that are typed in word. I tried to use the Windowselectionchange event of MS Word in the VB Program. The windowselectionchange event is fired whenever I move the cursor to a new location, press the delete key, made a new selection. However when I type in new text or press the enter button, or press the delete back arrow key the event is not fired
What is the way to know the characters that are added (including enter key press) or deleted by the user in Word so that automatic transliteration can be done as the user types in?
 
P

Peter Hewett

Hi raviki

Let me start by stating that I've never tried the WindowSelectionChange event.
The documentation states <Occurs when the selection changes in the active
document window>. Presumably this event is called for every character you type
since this changes the position of the selection object. Also presumably it
gets called every time you select some text or extend/decrease the amount of
selected text.

However, if it works as above you're going to have to write some extremely smart
code to use the selection range Word passes in and translate that into some kind
of action. Not to mention possible language detection/determination.

If the event handler is called for every character you type and every selection
change all this is going to take place through a COM interface. Given the
other Word objects you'll need to reference (more COM activity) to sense what's
going on I'd be interested to know how you add-in is going to perform!

If you've not already done so you might want to consider creating a Word
template and create the necessary VBA code and see if the WindowSelectionChange
works as advertised and whether you can determine what's going on in your
document. If you can get reasonable performance then port the code to VB6 which
will be fairly simple.

HTH + Cheers - Peter
 
C

Cindy M -WordMVP-

Hi Peter,
Let me start by stating that I've never tried the WindowSelectionChange event.
The documentation states <Occurs when the selection changes in the active
document window>. Presumably this event is called for every character you type
since this changes the position of the selection object. Also presumably it
gets called every time you select some text or extend/decrease the amount of
selected text.
Actually, it does not fire "as you type". Only when you use the mouse, navigation keys, tab through table cells... that kind of thing.

The "workaround" to trap "as you type" would be to map each possible keystroke to a macro, using KeyBindings...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :)
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Cindy M -WordMVP- > écrivait :
In this message, < Cindy M -WordMVP- > wrote:

|| Hi Peter,
||
||| Let me start by stating that I've never tried the WindowSelectionChange
event.
||| The documentation states <Occurs when the selection changes in the
active
||| document window>. Presumably this event is called for every character
you type
||| since this changes the position of the selection object. Also
presumably it
||| gets called every time you select some text or extend/decrease the
amount of
||| selected text.
|||
|| Actually, it does not fire "as you type". Only when you use the mouse,
navigation keys, tab
|| through table cells... that kind of thing.
||
|| The "workaround" to trap "as you type" would be to map each possible
keystroke to a macro, using
|| KeyBindings...

Ouch! What a nightmare!

Ravki, why not try something that sounds a lot simpler. Have your VB6 app do
its work after the fact. Let the user type its document and save it. Then
fire your App, let the user select a folder from your app and than all Word
documents in that folder will be transliterated, or the user could choose
specific documents from within that folder.
IMHO, to do what you want would generate so much overhead and slow down the
whole process so much that the user would hate it (and you by extension!).

Just my 2¢!
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
K

Klaus Linke

Hi Raviki,

Another solution might be to create a Unicode keyboard layout for the Indian
script... That would be a Windows solution that would work in other
programs, too. I haven't tried myself but heard that it's entirely possible.

If the script is too complex for that, you'd need to write an IME, which
would probably be harder.

You might ask in microsoft.public.word.internationalfeatures or in Windows
groups dealing with internationalization whether there's something available
already, or where to find further information.

Greetings,
Klaus
 

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