How to set focus to Word using automation

P

PromisedOyster

Our application integrates tightly with Word using automation.

In certain instances we are finding that Word has a dialog open but the
user is not aware of this because Word does not have focus.

How can we force Word to get focus.

I have tried the following but to no avail:

_wordApp.ShowMe();
_wordDoc.ActiveWindow.SetFocus();

(If we control the opening of Word then this works OK. However, if
attach to an existing instance of Word AND it was already maximised
then this is where we have the issue).
 
J

Jezebel

The better (and easier) solution is to make sure that Word doesn't display
any dialogs. If your application is (as you claim) tightly integrated, this
is not difficult.
 
P

PromisedOyster

There are a couple of instances where we do want to activate Word, ie
to show the results of a spellcheck and to show the document that has
been automatically produced (to give the user the option to change).

I neglected to say in the original post that we are also calling the
Activate() method.
 
J

Jezebel

If Word is activated, then dealing with the dialogs is the user's
responsibility. You really can't have it both ways: either Word is under
your app's control, or it's under your user's control.
 
P

PromisedOyster

Yes I understand this. All I am asking for is for is the Word
Automation commands to ensure that Word gets focus as the Activate()
nor the SetFocus() command does not always seem to work.
 

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