Keystroke trapping in VB6/Word - Component Request Pending

R

rgutter

I'm stumped by this one. I'm trying to trap an escape to allow my users
to abort a process, but the VB/Word combination is getting in my way.
Here's the general structure:

Main form calls module to:
Start word
Open Word document
Set bProcess = true
Set counter = 0
Do while counter<max and bProcess
Increment counter
Display counter etc. in Status form
DoEvents
If not bProcess then exit loop
Call Word macro
Loop
Cleanup

DoEvents allows the Status form's keypress event to trap Esc and clear
bProcess. The problem is that most of the processing takes place within
Word which is doing its thing behind the scenes, so if my user presses
Esc (or anything) when he has the form in the foreground he gets a
Component Request Pending warning:

An action cannot be completed because a component (document name -
Microsoft Word) is not responding. Choose "Switch To" to activate the
component and correct the problem.

Well, he can Retry, which does nothing, or Switch To, which gives a
glorious view of what Word's doing. But the Esc never makes its way to
the form's keypress event to allow me to abort the loop.

Any ideas?
 

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