check for running app

  • Thread starter Thread starter L3Tech
  • Start date Start date
L

L3Tech

Is there a way to check for a running program on a computer in vba and
if it isn't, start the program.

Ex.
Program to check for is domywork.exe
It is found in
c:\MyStuff\domywork.exe
 
Here is an example using Word

Dim wdApp As Object

On Error Resum Next
Set wdApp = GetObject("Word.Application")
On Error Goto 0
If wdApp Is Nothintg Then
Set mwdApp = CreateObject("Word.Application")
End If
--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
If not COM, you could try

AppActivate ("myapp")

where myapp is as shown in the Task Manager,

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
I don't know if I am understanding your reply.
While my code runs, I need to check to see if an external program is
running on the computer. If it is not, then I need to start that
program. The program is not a microsoft program.
 
If it is not COM (let's assume it is not) then test as I showed, and if not
there then Shell it. Here is an example using the Calculator program

On Error Resume Next
AppActivate "Calculator"
If Err.Number <> 0 Then
Shell "C:\Windows\system32\calc.exe"
End If

You will know the path and app name for Shell, you can check the app by
starting it and see what is in Task Manager.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Thanks
I got it to work.
For my info, what is COM?
I am using excel 97. Is this something new?
 
COM is another, older, term for Automation, which is probably MS's
preferred terminology these days. It's a technology supported by Visual
Basic and the Microsoft Office applications that enables one application to
work with another application's objects. So an Excel app can
create/read/write a Word document. The most common example you might see
here is Excel sending mail via Outlook using COM/Automation .

It was around with 97, and is still with us in 2003. It is an MS technology,
but there are other vendors that support COM/Automation as well, as it
allows them to use the MS apps and not have to write that function
themselves.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Back
Top