Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Prevent multiple instances of Excel from starting


Is there a command line switch that will prevent Excel from opening multiple
instances of the application? I develop under excel and use an interface to a
thrid party middleware product. If the user opens multiple copies of Excel
then the middleware doesn't know which one to use and it's operations tend to
become unpredictable.

If there isn't a way to prevent multiple instances, how about a way to
detect it?

- Rm
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Prevent multiple instances of Excel from starting

I am not aware of a way to limit excel to one instance. I did have to deal
with a similar problem and initially we tried using GetObject to get 'other'
excel instance, but it did not always work. We ended up using Windows API
calls to get processes and then check for excel.exe by.

If there's an elegant way to reliably do this then I am interested as well.
--
www.alignment-systems.com


"Robert Mulroney" wrote:


Is there a command line switch that will prevent Excel from opening multiple
instances of the application? I develop under excel and use an interface to a
thrid party middleware product. If the user opens multiple copies of Excel
then the middleware doesn't know which one to use and it's operations tend to
become unpredictable.

If there isn't a way to prevent multiple instances, how about a way to
detect it?

- Rm

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Prevent multiple instances of Excel from starting

Hi John,

Thanga posted a C# routine here in message, see message #9 date view

http://tinyurl.com/9pbjv

I couldn't get it to work but probably due to my minimal knowledge of making
anything work in C# !

I have an "in-elegant" VBA method which is reliable enough for my purposes
though I wouldn't distribute as a production app, at least not as is. Maybe
a timing issue, occasionally fails first time though normally works on
second attempt. I briefly described it in message #6 of same thread.

Regards,
Peter T
pmbthornton gmail com


"John.Greenan" wrote in message
...
I am not aware of a way to limit excel to one instance. I did have to

deal
with a similar problem and initially we tried using GetObject to get

'other'
excel instance, but it did not always work. We ended up using Windows API
calls to get processes and then check for excel.exe by.

If there's an elegant way to reliably do this then I am interested as

well.
--
www.alignment-systems.com


"Robert Mulroney" wrote:


Is there a command line switch that will prevent Excel from opening

multiple
instances of the application? I develop under excel and use an interface

to a
thrid party middleware product. If the user opens multiple copies of

Excel
then the middleware doesn't know which one to use and it's operations

tend to
become unpredictable.

If there isn't a way to prevent multiple instances, how about a way to
detect it?

- Rm



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Prevent multiple instances of Excel from starting


Thanks guys. I've explored some options that use the Windows API to check
the list of running processes. I don't really want to give my users the
capability to run scripts that simply terminate processes. That could lead to
some, well.... "problems".

I've noticed that a lot of objects in excel have an "Application" property.
There must be someway that I can compare "Applications" for each open
document and terminate all but one using the "Application.Quit". That seems a
little safer to me.

Any thoughts?


- Rm

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Prevent multiple instances of Excel from starting

I suppose if you are administrating use of Excel in your organisation it
might be OK for you to close your colleagues' Excel instances in an orderly
way. But if that's not the case my "thought", as you asked, would be don't
even consider doing that!

In your OP you said "I develop under excel and use an interface to a
thrid party middleware product"

I don't follow the reason you need to close all but one instance, and the
criteria by which you would leave a given instance open.

If you know the FullName (not simply file name) of a particular file that's
of interest, if open it's normally possible to attach a ref to its instance
with GetObject(FullName).Parent.

Or maybe just start your own instance.

Regards,
Peter T

"Robert Mulroney" '''' wrote in message
...

Thanks guys. I've explored some options that use the Windows API to check
the list of running processes. I don't really want to give my users the
capability to run scripts that simply terminate processes. That could lead

to
some, well.... "problems".

I've noticed that a lot of objects in excel have an "Application"

property.
There must be someway that I can compare "Applications" for each open
document and terminate all but one using the "Application.Quit". That

seems a
little safer to me.

Any thoughts?


- Rm





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Prevent multiple instances of Excel from starting

Perhaps I didnt make it clear initially, the problem I have stems from
having multiple instances of the €śExcel Task€ť running at the same time, not
multiple xl documents.

To see what I mean: Double click your excel icon. Minimise the window and
double click the icon again. Go to your task manager (sort by task name) and
youll see that there are two instances of Excel processing at the same time.
Thats want I want to prevent, not multiple windows on the start bar.

I don't have some malicious intent on making life difficult by randomly
closing peoples work for them. It would be much better to prevent a new excel
instance starting then have to close it after start €“ hence my original
question. The idea of closing tasks came up if it is not possible to prevent
multiple start-ups. In that sence my criteria for closing excel apps would be
"if one is running close the new one and maximise the old"

All Office products that run concurrently seem to €śknow€ť about each other.
They interact and react to each other. For example Outlook uses Word to
format emails and spellcheck. Thats one of the coolest things about
developing with Office tools. Its this interaction between two instances of
Excel that seem to be causing the problem, confusing the 3rd party product.

Hopefully I'm making more sence. Thanks for you help.

- Rm

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent multiple instances in Excel 2007 Steve Excel Discussion (Misc queries) 6 July 30th 09 06:40 PM
Excel starting multiple instances of IE Paul Hodges New Users to Excel 4 September 1st 05 07:35 PM
Prevent Excel closing all workbook instances when clicking on "X" Deeptech-NM Excel Discussion (Misc queries) 8 July 4th 05 01:36 PM
Files open when starting-How to prevent Blair Setting up and Configuration of Excel 2 February 10th 05 03:58 PM
Prevent Excel creating new instances of Excel Jordi[_2_] Excel Programming 2 November 15th 03 11:51 PM


All times are GMT +1. The time now is 12:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"