Dave-
I would use the Win32 API function SetForegroundWindow()
for this.
Put this code in a new module in Word VBA:
'---------------------------------------------------
Option Explicit
Public Declare Function GetForegroundWindow Lib "user32" _
() As Long
Public Declare Function SetForegroundWindow Lib "user32" _
(ByVal hwnd As Long) As Long
'----------------------------------------------------
Then, before you call Outlook from your Word code, add
these lines:
'------------------------------------------------------
Dim intHWND As Long 'holds window handle
intHWND = GetForegroundWindow() 'Get current Top window
'------------------------------------------------------
Immediately after you call Outlook in your code, add this
line:
'-------------------------------------------------------
SetForegroundWindow (intHWND) 'Restore previous Top window
'-------------------------------------------------------
That should do it for you.
***
The Win32 API is your friend!
See
http://www.mentalis.org/apilist/apilist.php
and
http://www.mentalis.org/index2.shtml for more on the
API.
-Andrew
========================================================
-----Original Message-----
I have several Word XP Templates that access Outlook
Contact Folders. Whenever the user has Outlook open when
the code accesses Outlook the desktop puts the Outlook
window over top the Word window. I have tried to the
following code to return the Word window over top the
Outlook window but it isn't working:
With Tasks("Outlook.exe")
.Close
End With
If Outlook isn't already open on the user's desktop then
this isn't a problem, however, when it is open it is very
annoying.