Task Detection & Switching

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a button in my form that opens up an application. I would like to
change that just slightly though. Is there any way to detect whether or not
the program is already running, and if it is, task switch to that program?
Or if it isn't open already, then it would just go ahead and run it.

Thanks,

Nick
 
It depends on what application you're trying to opening.

If, for instance, you're trying to use Word, you can do something like:

On Error Resume Next

Dim objWord As Object

Set objWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
Set objWord = CreateObject("Word.Application")
End If

However, you need to know how to refer to the application, and not all
applications expose themselves for automation this way.

http://www.mvps.org/access/api/api0007.htm at "The Access Web" shows how to
use the application's Class Name to determine whether or not it's currently
running. If you don't know the Class Name of your particular application,
the code in http://www.mvps.org/access/api/api0013.htm should be able to
help you find it.
 

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

Back
Top