468,283 Members | 1,993 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,283 developers. It's quick & easy.

Opening another program and maximising, and check whether already open

Hi,

I use the below for the user to view their outlook calendar

Sub DisplayInbox()
Dim myolApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Set myolApp = CreateObject("Outlook.Application")
Set myNameSpace = myolApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
myFolder.Display
End Sub

I have two problems;

1. This does not check if outlook is already open, so can end up with
2 instances of the program open

2. Outlook is minimised when opened (annoying!) (although this may be
solved by the solution to the above problem.

Many thanks,

Mar 24 '07 #1
1 2557
On 24 Mar 2007 13:09:26 -0700, "keri" <ke********@hotmail.comwrote:
>Hi,

I use the below for the user to view their outlook calendar

Sub DisplayInbox()
Dim myolApp As Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.MAPIFolder
Set myolApp = CreateObject("Outlook.Application")
Set myNameSpace = myolApp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderCalendar)
myFolder.Display
End Sub

I have two problems;

1. This does not check if outlook is already open, so can end up with
2 instances of the program open

2. Outlook is minimised when opened (annoying!) (although this may be
solved by the solution to the above problem.

Many thanks,
This function will return -
0 if Outlook is not installed on the machine
1 if Outlook is installed but not currently running
2 if Outlook is installed and currently running

(modified from code provided by Stephen Lebans)

Function fIsOulookThere() As Integer
' Open the installed Version of MS Outlook
Dim OL As Object

'See if Outlook is running
Err.Clear
' Is Outlook running?
Set OL = GetObject(, "Outlook.Application")
' Error if not running
If Err.Number <0 Then
' Clear Error object
Err.Clear
'Create a new instance of Outlook
Set OL = CreateObject("Outlook.Application")
If Err.Number <0 Then
'not installed
fIsOulookThere = 0
Else
'installed but not running
fIsOulookThere = 1
End If
Else
'yes it is running
fIsOulookThere = 2
End If

If Not IsEmpty(OL) Then Set OL = Nothing

End Function

Wayne Gillespie
Gosford NSW Australia
Mar 24 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by PM | last post: by
14 posts views Thread by Mike - EMAIL IGNORED | last post: by
14 posts views Thread by D. Alvarado | last post: by
9 posts views Thread by BLUE WATER | last post: by
6 posts views Thread by bole2cant | last post: by
7 posts views Thread by emanshu | last post: by
reply views Thread by bbrewder | last post: by
16 posts views Thread by Phil Stanton | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.