473,394 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 2794
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: PM | last post by:
Has anyone found a way to open a file exclusively where it will fail if the file is already open, i have tried the following _FileStream = new FileStream(@"C:\Data.txt", FileMode.Open,...
14
by: Mike - EMAIL IGNORED | last post by:
Using RH9, from this fragment: fstream theStream_; string fPath = "myFile"; int mode = O_EXCL | O_CREAT; theStream_.open(fPath.c_str(),mode); I get the failure shown below. ...
44
by: Carlos Andr?s | last post by:
Hi everybody. I've got a problem. I'd like to avoid opening a new window when you have pressed the shift key and you click in the left button of the mouse. I've tried the next solution, in the...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
9
by: BLUE WATER | last post by:
Help, When I am finished entering in data into my form A, I press the save button that saves this new data to a new record. However I would like my other form to open at a specific record, the...
6
by: bole2cant | last post by:
The error I get is: Cannot access a disposed Object named "Form2". Object name "Form2". Here is the sequence which gives the error. Start program. Form1 comes up and has a button to choose...
7
by: emanshu | last post by:
HI all, I an designing an application in C++. i want to open file requested by end user but i want to reflect an error to user if file is already opened by some other application.. will anybody...
0
by: bbrewder | last post by:
I am struggling with some MSAccess automation issues. Basically, we have a .Net application that uses MSAccess for reporting (legacy code). We are able to launch MSAccess fine and even work with...
16
by: Phil Stanton | last post by:
I have a form with a button which is supposed to open an Excel file (With lots of Macros /VBA) in it. The Excel file gets it's data from the Access program Here is the code Private Sub...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.