Hi DaveL,
This little app looks at the Title Bar to see if Outlook is on it, if not, opens Outlook. Paste this into a new Module, save the module as anything:
Declare Function EnumWindows Lib "user32.dll" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowTextLength Lib "user32.dll" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function GetWindowText Lib "user32.dll" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetActiveWindow Lib "user32.dll" () As Long
Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal Msg As Long, wParam As Any, lParam As Any) As Long
Global booIsThisOpen As Boolean
Global strIsThisopen As String
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
On Error Resume Next
Dim slength As Long, TitleBar As String
Dim retval As Long
Static winnum As Integer
booIsThisOpen = False
winnum = winnum + 1
slength = GetWindowTextLength(hwnd) + 1
If slength > 1 Then
TitleBar = Space(slength)
retval = GetWindowText(hwnd, TitleBar, slength)
If InStr(TitleBar, strIsThisopen) Then
booIsThisOpen = True
Exit Function
End If
End If
EnumWindowsProc = 1
End Function
To test it, paste this into the Click event of a Button:
strIsThisopen = "Microsoft Outlook"
Call EnumWindows(AddressOf EnumWindowsProc, 0)
If booIsThisOpen = False Then
Call Shell("OutLook", 1)
End If
Obviously you don't need to use the Shell to Outlook, it's just there to see if it works for you.
Good luck
Bill