Only One Instance

The following code snippet avoids an application to run a separated instance. This code must preceed any other command and preferably be executed before any other module is loaded.

Private Sub Form_Load()

    If App.PrevInstance = True Then
        MsgBox "Application already running.", vbInformation, App.Title
        Unload Me
        Exit Sub
    End If

End Sub
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License