Results 1 to 3 of 3

Thread: Giving focus to Word application then waiting before closing it

  1. #1

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Giving focus to Word application then waiting before closing it

    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.
    This world is not my home. I'm just passing through.

  2. #2
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    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.
    Please rate my post.

  3. #3

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    ** RESOLVED **

    Thanks Shawn,

    That works really well.

    Tris.

    PS I spent a month working in Houston last year. Is the Fox and Hound still there?
    This world is not my home. I'm just passing through.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width