|
-
Mar 26th, 2003, 10:58 PM
#1
Thread Starter
Hyperactive Member
Where to put code in MSWord
Using MSWord 2000, I'm trying to replace a word the user types with another word. That's no problem using the words collection, however, I would like to monitor the document as the user types so that when the word "puzzle" is typed my program will automatically replace it with the word "enigma". I'm not concerned with the actual code to make this work, but in which event to place the code. I am familiar with the document object and the application object but neither allow this type of monitoring, at least I don't think they do. Is there another object with an event that tracks the changes in the word document as the document is typed? Thanks for any help.
Sometimes what you're looking for is exactly where you left it.
-
Mar 27th, 2003, 02:35 AM
#2
I "cheated".
I used the macro-recorder, chanded the auto-word-replace (I hope the english expression fits) and used this code.
If I understand you correctly, you only want that to be in fact in this specific word-file. To do that I placed the above recorded code into the _open event of this document and did put the reverse code (erase the word-change for puzzle) in the _close event.
I know, that way it will also be used for any document that is opened while the document holding that is open.
Anybody with a better one?
Last edited by opus; Jul 18th, 2007 at 02:51 AM.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Mar 27th, 2003, 03:32 AM
#3
Thread Starter
Hyperactive Member
Thanks for your reply. What I really need though is to monitor the input on the fly. I need to change the word only if it is typed at a certain tab stop. I'm just wondering if an object exists with events that will fire when a user types a character on the page. For instance, if you misspell a word it will be underlined in red automatically by MS Word's built in spell checker, so each word is being monitored on the fly. Is there an object where I can monitor the input as it occurs? Thanks again.
Sometimes what you're looking for is exactly where you left it.
-
Mar 27th, 2003, 04:08 AM
#4
I understand, but so far I didn't find an object with such an event.
However, the code given does change it on the "fly". It uses the build-in function of Word.
Did you try the file?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Mar 27th, 2003, 03:00 PM
#5
Thread Starter
Hyperactive Member
No I didn't try your file, but just by looking at it I know it isn't monitoring user input it is monitoring the occurance of a word, which is great and usefull but not enough. I need to manipulate words in many different ways depending on what is actually typed ie. verb, noun, capitals, colors, ect. and I think the only way to do that is when the instance actually occurs. As in MS Excel I can monitor every single change with built in events, but in MS Word I guess that can't be done and I don't see the reason why.
For instance, how would I pop open a form if the user has typed the word "puzzle" at 3 different tab stops throughout the document? I don't really need the code to do that, but I do need to know where that code would go. Thanks again, I'm going to do some more research on the build-in function.
Sometimes what you're looking for is exactly where you left it.
-
Mar 27th, 2003, 03:06 PM
#6
Sorry, I misunderstood your question a bit. I was focusing too much on your example.
As I said I also tried to find such an Event, with no success, Sorry.
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|