CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 1999
    Posts
    1

    Wait until external process is complete

    I am using visual basic for an application that searches an ODBC database for information and stores the information on an ms access database. From this application I shell open a word document and then Sendkeys() to merge the word doc with the data stored on the access database. I also send keys to close the document and bring the user back the VB application.

    The problem arises when the application sends keys prematurely before Word is finished with its current process. Is there an API that can tell you when an external process is complete before continuing on with the executed code? I've tried using a timer but depending on how many documents will be merged requires more time or less. If there is not an API that does this effectively... Is there some other way??




  2. #2
    Join Date
    Oct 1999
    Posts
    25

    Re: Wait until external process is complete

    Yes, I've done it with C++ using the Win32 API, Instead of ShellExecute, use CreateProcess, it's a little more involved, but then once you've spawned the external executable you can call WaitForSingleObject, which will wait for the external process to complete ( it has a timeout parameter but it can be set to infinite). All the declares and such should be in the API Text Viewer.

    Sky1000


  3. #3
    Join Date
    May 1999
    Posts
    3,332

    Re: Wait until external process is complete

    IMHO if you want to control Word, you should use its automation interface. It's much more reliable and gives you much more control over Word's behavior.


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

Featured