Discussion Locked

Excel97 & VBA: verify another app is ru

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Using Excel97, I need to verify another application is running before attempting a DDE link to it. I want to avoid the Windows dialog prompting the user to start the app when the DDEInitiate fails.

I imagine App.PrevInstance will work, but can'tfind an implementation example.

Examples, or better ideas, are greatly appreciated.

Ray

2 replies

by tclere

The App.PrevInstance will only check if the current application is already running. This will prevent a user opening 2 instances of the same application.

If App.PrevInstance = True Then
MsgBox App.Title & " is already running!"
End
EndIf

If you want to see if a different application is running you have a couple choices. If the app has a window opened you can just look for the window, assuming you know the title.

Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

hwnd = FindWindow(vbNullString, sAppTitle) 'sAppTitle: "Title of Window"

If hwnd <> 0 Then
'You Found it
'Do your Stuff
Endif

If the app does not have a window opened but it shows in Task Manager, I have posted a solution here that can be modified to suit your needs.

http://www.tek-tips.com/faq.cfm?spid=222&page=1&CFID=3714227&CFToken=43607892#61

Let me know if you need more info.

This discussion is closed to new replies.