Try this:
Put the code below in a VBA code module.
1- Check subroutine 'window_action' - make sure the Outlook window caption
is specified here. It doesn't have to be the entire caption, but enough to
uniquely identify the Outlook window.
2- From your event that you wish to minimize the external (Outlook) application,
call subroutine 'window_action'.
This should minimize the Outlook window... Let me know how you make out.
Option Explicit
Public psAppNameContains As String
Public pbfound As Boolean
Public thehwnd As Long
Public Declare Function GetWindowText& Lib "user32" Alias "GetWindowTextA" (ByVal hwnd _
As Long, ByVal lpString As String, ByVal cch As Long)
Public Declare Function ShowWindow& Lib "user32" (ByVal hwnd As Long, ByVal ncmdshow As Long)
Public Declare Function EnumWindows Lib "user32" _
(ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Const SW_MINIMIZE = 6
Public Sub window_action()
AppActivateByStringPart ("Outlook")
If thehwnd > 0 Then
Dim showw As Long
showw = ShowWindow(thehwnd, SW_MINIMIZE)
Else
MsgBox ("Outlook window not found")
End If
End Sub
Public Function AppActivateByStringPart(StringPart As String) As Boolean
Dim lRet As Long
psAppNameContains = StringPart
lRet = EnumWindows(AddressOf CheckForInstance, 0)
AppActivateByStringPart = pbfound
pbfound = False
End Function
Public Function CheckForInstance(ByVal lhwnd As Long, ByVal _
lParam As Long) As Long
Dim sTitle As String
Dim lRet As Long
Dim iNew As Integer
If Trim(psAppNameContains = "") Then
CheckForInstance = False
Exit Function
End If
sTitle = Space(255)
lRet = GetWindowText(lhwnd, sTitle, 255)
sTitle = StripNull(sTitle)
If InStr(sTitle, psAppNameContains) > 0 Then
CheckForInstance = False
pbfound = True
thehwnd = lhwnd
Else
CheckForInstance = True
End If
End Function
Public Function StripNull(ByVal InString As String) As String
Dim iNull As Integer
If Len(InString) > 0 Then
iNull = InStr(InString, vbNullChar)
Select Case iNull
Case 0
StripNull = InString
Case 1
StripNull = ""
Case Else
StripNull = Left$(InString, iNull - 1)
End Select
End If
End Function