By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,876 Members | 1,452 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,876 IT Pros & Developers. It's quick & easy.

Opening another program and maximising, and check whether already open

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.