Connecting Tech Pros Worldwide Help | Site Map

Opening another program and maximising, and check whether already open

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 24th, 2007, 08:15 PM
keri
Guest
 
Posts: n/a
Default 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,


  #2  
Old March 24th, 2007, 11:35 PM
Wayne Gillespie
Guest
 
Posts: n/a
Default Re: Opening another program and maximising, and check whether already open

On 24 Mar 2007 13:09:26 -0700, "keri" <keridowson@hotmail.comwrote:
Quote:
>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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.