I don't know how to minimize Outlook from Access VBA.
Only way I know to close an app from Access VBA is to kill all processes of the app. Don't ask me to explain this code - I found it and just know it works for my requirements.
' ProcessKillLocal.vbs
' Sample VBScript to kill a program
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.7 - December 2010
' ------------------------ -------------------------------'
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strProcessKill
strComputer = "."
strProcessKill = "'outlook.exe'"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = " & strProcessKill )
For Each objProcess in colProcess
objProcess.Terminate()
Next
'WSCript.Echo "Just killed process " & strProcessKill & " on " & strComputer
'WScript.Quit
'End of WMI Example of a Kill Process
How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
I never got it to work real well but, I modified the code I linked to in post #4 to send outlook to the task tray. I say tray verses task bar. Let me know if that is something you want to explore. It can be done. It just confused the user so I reverted. Not sure if it can be modified to Task "BAR"
Finally I decided to use the open outlook code provided by June7, placing it in this part of the code:
If Err Then 'Outlook is not open
OpenOutlook
Set olApp = CreateObject("Outlook.Application") 'Create a new instance of Outlook
End If
I configured outlook to launch minimized by editing in the Start menu properties
The pro is that I don't spend time and resources closing outlook when I am probably using it next. The con is that I have to manually close it when I finish.
So...
that would be great. User doesn't need to know outlook is there, just that is working.I never got it to work real well but, I modified the code I linked to in post #4 to send outlook to the task tray. I say tray verses task bar. Let me know if that is something you want to explore. It can be done. It just confused the user so I reverted. Not sure if it can be modified to Task "BAR"
The issue I never resolved is every time the user fired the request via a control, it would put Outlook in the tray regardless if it was already open. Calling the function would hide Outlook if it was already running.
I just need to find a way to call the "Hide" part in an If Then statement.
I started digging through how I go about checking for and launching Outlook. I am polishing up my existing code and will import it into a blank DB to post here at a later time. Meanwhile, here is code to act like you are launching Outlook from the start menu with a twist. It puts in the "Task Tray". The downfall is this code snipit will always put it in the Task Tray. You have to select when you call it and this is what I am working to resolve.
Open Outlook and have it runn in the Task Tray:
stAppName = "C:\Program Files\Microsoft Office\OFFICE11\Outlook.exe" 'Locate the app's .EXE file
Call Shell(stAppName, vbMinimizedFocus)
PS:
You need to verify the directory for your version of Outlook.