Is Application Open?

A

AHopper

When I open form "OnePGoodPack" I want to find out if an
application located at c:/winwedge/winwedge.exe is open.
If the application is open I want to close it and open it
with the right configuration
If the application is closed I want to open it. I have the
functions that will open the application with various
configurations, however if I use the code and the
application is already open it creates an error.
Below is one of the functions that can open the
application. I presently call it from the On Click event
of a command button.

Function LaunchSpiderWedge()
Dim CmdLine As String
Dim RetVal As String
Dim X As Date
' This function will launch the Wedge feeding it the
' name of a configuration file on the command line
' causing the Wedge to automatically load the config
' file and activate itself
CmdLine = "C:\winwedge\winwedge.exe
C:\winwedge\SpiderWedge.SW3"

RetVal = Shell(CmdLine)

' wait for roughly 2 seconds
' give wedge time to load and activate itself

X = Now + 0.00002
Do While Now < X
DoEvents ' allow other Windows processes to continue
Loop

' set the focus back to Access
AppActivate "Microsoft Access"

End Function

In the On Close event of a form "OnePGoodPack" I would
like to find out if an application located at
c:/winwedge/winwedge.exe is open and if it is I want to
close it.

I have the function below to close the application
however, if I run the function and the application is
already closed I get an error which freezes my application.

Function KillWedge() ' This function unloads the Wedge
from memory
Dim Chan As String
' initiate DDE channel with wedge on COM1
Chan = DDEInitiate("WinWedge", "Com1")

' send AppExit command to Wedge
DDEExecute Chan, "[AppExit]"

' close the DDE Channel
DDETerminate Chan

End Function

Thank you in advance for your help.

Allan
 
A

AHopper

Doug
Thank you for your help.
Allan
-----Original Message-----
If you know the class name of the application, you can use the code in
http://www.mvps.org/access/api/api0007.htm at "The Access Web" to determine
whether or not it's running. You can use the code in
http://www.mvps.org/access/api/api0013.htm to determine the class name.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


When I open form "OnePGoodPack" I want to find out if an
application located at c:/winwedge/winwedge.exe is open.
If the application is open I want to close it and open it
with the right configuration
If the application is closed I want to open it. I have the
functions that will open the application with various
configurations, however if I use the code and the
application is already open it creates an error.
Below is one of the functions that can open the
application. I presently call it from the On Click event
of a command button.

Function LaunchSpiderWedge()
Dim CmdLine As String
Dim RetVal As String
Dim X As Date
' This function will launch the Wedge feeding it the
' name of a configuration file on the command line
' causing the Wedge to automatically load the config
' file and activate itself
CmdLine = "C:\winwedge\winwedge.exe
C:\winwedge\SpiderWedge.SW3"

RetVal = Shell(CmdLine)

' wait for roughly 2 seconds
' give wedge time to load and activate itself

X = Now + 0.00002
Do While Now < X
DoEvents ' allow other Windows processes to continue
Loop

' set the focus back to Access
AppActivate "Microsoft Access"

End Function

In the On Close event of a form "OnePGoodPack" I would
like to find out if an application located at
c:/winwedge/winwedge.exe is open and if it is I want to
close it.

I have the function below to close the application
however, if I run the function and the application is
already closed I get an error which freezes my application.

Function KillWedge() ' This function unloads the Wedge
from memory
Dim Chan As String
' initiate DDE channel with wedge on COM1
Chan = DDEInitiate("WinWedge", "Com1")

' send AppExit command to Wedge
DDEExecute Chan, "[AppExit]"

' close the DDE Channel
DDETerminate Chan

End Function

Thank you in advance for your help.

Allan


.
 

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

Similar Threads


Top