What's the way to hide and unhide an external application, such as Outlook. I mean, I want the program to be running, but on the background and that could not get focus unless you unhide it. Am I clear?
Printable View
What's the way to hide and unhide an external application, such as Outlook. I mean, I want the program to be running, but on the background and that could not get focus unless you unhide it. Am I clear?
Use this code,
put this in a module:
VB Code:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Public Const WM_CLOSE = &H10
and put this under a command button
VB Code:
sdf = FindWindow(vbNullString, "AppNameHere") 'find the window If sdf = 0 Then MsgBox "Couldn't find App" Else retval = ShowWindow(sdf, SW_HIDE) ' the command to hide the window End If
I think that should work, if you get any errors tell me;)
oh and you can show it using this code
VB Code:
sdf = FindWindow(vbNullString, "AppNameHere") 'find the window If sdf = 0 Then MsgBox "Couldn't find App" Else retval = ShowWindow(sdf, SW_SHOW) ' the command to show the window End If
Thanks a lot, Kings. I've already figured out the "show" way, with your first message ;-)
That DID hide and show the outlook.