PDA

Click to See Complete Forum and Search --> : Giving focus to Word application then waiting before closing it


trisuglow
Feb 1st, 2002, 09:59 AM
I'm writing an application that opens up an instance of Word.

I can open Word. I can also check if a previous instance of Word is running. I can even send a message to the previous instance and make it close down.

My problem is this:

If there is an unsaved document in the previous instance of Word the user gets a prompt to save their work. I want to do the following;

1. Send Word a message to bring it to the front of the screen.
2. Wait until the user has saved their work.

After that I can carry on and close the instance.

I've want to make this work on Win95/98/2000 and NT with all versions of Word. I've found some promising looking bits of code on this site and in MSDN, but I can't seem to get them to work.

Tris.

Shawn N
Feb 2nd, 2002, 01:43 PM
Use

Private Declare Function BringWindowToTop Lib "user32" ( _
ByVal hwnd As Long) As Long

against Word's window and put a do/loop until you don't find Word.

trisuglow
Feb 4th, 2002, 03:48 AM
Thanks Shawn,

That works really well.

Tris.

PS I spent a month working in Houston last year. Is the Fox and Hound still there?