Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i be sure a program is already running

Status
Not open for further replies.

stx

Programmer
Sep 24, 2002
62
BE
Hi

I want my program to start up outlook when pressed on a button, but only if it isn't already running, by using the shell command.

How can i check if outlook is running or not?

thnx
 
You can use COM automation to create/get an instance of the application, eg:

dim objOutlook as object = nothing

try
objoutlook = getobject("Outlook.Application")
catch
end try

if objOutlook is Nothing then objOutlook = creatobject("Outlook.Application")

 
neilharris

I get an error when using your sugested code:

try
objoutlook = getobject("Outlook.Application")
catch
end try

On the getobject-statement i get the error 'cannot create activeX-component' in my catch clause.

This error occurs when outlook is closed and/or open.

Any thoughts?

thnx
 
Try this:

Code:
        Dim objOutlook As Object

        Try
            objOutlook = GetObject(Class:="Outlook.Application")
        Catch ex As Exception
            objOutlook = CreateObject("Outlook.Application")
        End Try

Hope this helps.

- Glen

Know thy data.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top