Option Explicit
'//WIN32API Function
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
'//WIN32API Constant
Private Const SW_RESTORE = 9
Sub Main()
Dim hwnd As Long
'//Check for Previous Instance
If App.PrevInstance Then
hwnd = FindWindow(0&, "App Window Title Here")
If hwnd <> 0 Then
SetForegroundWindow hwnd
ShowWindow hwnd, SW_RESTORE
End
End If
End If
'//Continue load the Main Form
Load frmMain
frmMain.Show
End Sub