I like to keep everyone updated, this is what I ended up doing:
Code:Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long Declare Function EnumWindows Lib "user32" (ByVal lpFunc As Long, ByVal lParam As Long) As Long Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal nMaxCount As Long) As Long Public lngOutlookHWnd As Long Public Function EnumWindProc(ByVal hWnd As Long, ByVal lParam As Long) As Long Dim strTitle As String Dim lngTemp As Long strTitle = String(255, 0) lngTemp = GetWindowText(hWnd, strTitle, 255) If Left(strTitle, lngTemp) = "Microsoft Outlook" Then lngOutlookHWnd = hWnd EnumWindProc = 0 Exit Function End If EnumWindProc = 1 End Function Public Function GetOutlookHWnd() As Long EnumWindows AddressOf EnumWindProc, 0 End Function Public Function EmailIntro(lngContactID As Long) On Error GoTo Error_EmailIntro Dim appOutlook As Outlook.Application Dim miMail As Outlook.MailItem Dim rsIntroEmailInfo As DAO.Recordset Dim strFileName As String Dim lngTemp As Long Set appOutlook = New Outlook.Application 'Make sure Outlook is shown and maximized GetOutlookHWnd ShowWindow lngOutlookHWnd, SW_SHOWMAXIMIZED Set miMail = appOutlook.CreateItem(olMailItem) ... ETC
Basically, I enumerate the windows to find the window with the text "Microsoft Outlook" then I set that particular windows hWnd to a global variable, which I pass to the ShowWindow function.
Thanks anyways guys!




Reply With Quote