Hi,
I am trying to force Excel window as foregrond from VBA window using some win32 API.But this is not helping out.I followed the steps below.

1.Open Excel
2.Press ALT+F11 to open VBA window
3.Double click the ThisWorkbook and paste the following code in the coding area

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

Public Sub Test()
Dim exlHandle As Long
Dim exlTitle As String
exlTitle = Application.Caption
exlHandle = FindWindow(vbNullString, exlTitle)
SetForegroundWindow (exlHandle)
End Sub

Call the method Test from VBA immediate window like below and press enter key there.

call ThisWorkbook.Test

It suppose to set Excel as forground but not.Any suggestion?

Regards,
Rajanbabu