I've found this code in this forum

Private sub Form_Load()
'see if there is an istance already
If App.PrevInstance Then
msgbox "Application is already running"
AppActivate App.Title
'send the key (here SHIFT key) to set the form from the Prev Instance to the top
SendKeys "+", True

'Terminate the new instance
Unload Me
End if
End sub

However, It doesn't appear to work for me.
(I don't care about the SendKeys() and AppActivate() calls, so I'm down to this)

Private sub Form_Load()
'see if there is an istance already
If App.PrevInstance Then
'Terminate the new instance
Unload Me
End if
End sub



I've tried running this


If App.PrevInstance Then
'Terminate the new instance
Exit Sub
End if


as the first line of code in my main() routine as well, and it just does not detect another instance of the program running.

What would cause this ?