Am 29 Mar 2006 13:19:57 -0800 schrieb Bernie:
Bernie, the solution is not as simple as you might think.
You need to use some Win32 APIs to bring the windows into the foreground and
back again. While the Excel Application object exposes its window handle
Outlook doesn´t, so you need to find it yourself.
This sample (code in Excel) works if not Word is the e-mail editor:
Private Declare Function SetForegroundWindowA Lib "USER32" Alias
"SetForegroundWindow" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "USER32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Function GetInspectorHandle(ByVal sCaption As String) As Long
GetInspectorHandle = FindWindow("rctrl_renwnd32", sCaption)
End Function
Sub test()
Dim app As Object
Dim mail As Object
Dim hnd As Long
Set app = GetObject(, "outlook.application")
Set mail = app.createitem(0)
mail.display
' get mail window´s handle
hnd = GetInspectorHandle(mail.GetInspector.Caption)
' bring excel into foreground
SetForegroundWindowA Application.hwnd
MsgBox "hallo"
' bring mail window into foreground again
SetForegroundWindowA hnd
End Sub

Signature
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --
> Since I am not any great Visual Basic for Applications (VBA) programmer
> I am probably missing something very simple here. I searched for an
[quoted text clipped - 24 lines]
>
> Bernie
Bernie - 30 Mar 2006 20:55 GMT
Thanks, Michael. I was sure hoping for something simple. But since
the concern is to move focus to Excel then we might not have to worry
about getting back to Outlook.
Thanks for the quick response....we will give it a try.
Bernie