Olá, Vaca.
Coloque este código num módulo, ele faz isso que você quer.
Public Const GW_HWNDPREV = 3
Declare Function OpenIcon Lib "user32" (ByVal hwnd As Long) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
Public sTrab As String * 255
Public Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Declare Function GetComputerName Lib "kernel32" _
Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Sub Main()
If App.PrevInstance Then
ActivatePrevInstance
Else
Load frmFORMULARIO
End If
End Sub
Sub ActivatePrevInstance()
Dim OldTitle As String
Dim PrevHndl As Long
Dim result As Long
OldTitle = App.Title
App.Title = "Programa em execução"
PrevHndl = FindWindow("ThunderRTMain", OldTitle)
If PrevHndl = 0 Then
PrevHndl = FindWindow("ThunderRT5Main", OldTitle)
End If
If PrevHndl = 0 Then
PrevHndl = FindWindow("ThunderRT6Main", OldTitle)
End If
If PrevHndl = 0 Then
Exit Sub
End If
PrevHndl = GetWindow(PrevHndl, GW_HWNDPREV)
result = OpenIcon(PrevHndl)
result = SetForegroundWindow(PrevHndl)
End
End Sub
É bem provável que isto lhe sirva.
Rogério.