PDA

View Full Version : Sleeper: Locate and Open Outlook



tyndale2045
12-09-2008, 11:20 AM
I want to force outlook to open (so that items waiting in the outbox will be sent). The following code works just fine to open it up.

But there are some users (in our office) who have multiple hard drives on their computers. Hence, Outlook might not be located on the C drive, and everyone might not have the exact same version of MS Office in the exact same place. Is there any way to do a search for the specific location of Outlook, dump that location info into a string, and then use that string in the shell command below? If so, I haven't found out how. And any advice will be appreciated.



Sub Force_Outlook_To_Open()
MyAppID = Shell("C:\Program Files\Microsoft Office\OFFICE11\Outlook.exe", 1)
End Sub

holshy
12-09-2008, 11:49 AM
Sub Force_Outlook_To_Open()
Dim olkApp
Dim nsp
Dim sycs
Dim syc
Set olkApp = CreateObject("Outlook.Application")
Set nsp = Application.GetNamespace("MAPI")
Set sycs = nsp.SyncObjects
For Each syc in sycs
syc.Start
Next
End Sub
This creates an outlook application and then starts all available Send/Receive operations. It's is completely independent of where in the file structure Outlook is installed. Outlook will not be visible to the user for this.