How to open new instance of excel if excel is already open?

G

Guest

Hi All

I'm kind of fighting with excel;-) I open an excel file by automation and
disable a lot of things, like save and save as...and a lot more. Now if this
excel is open and i try to open another excel file (this time with a
doubleclick on a normal excel file). the 2. file is opened in the same
instance(same excel.exe Process) and gets also all the disabled stuff i made
for the 1. excel file. Is there a way to tell the 2. file not to open in the
same instance but create a new one by default? or can i somehow lock my
excel.exe for other excel files, so that they automatically create a new exel
process?

thanks for the help
m.ahrens
 
D

DM Unseen

Did you enable in Tools->General ignore other applications? This will
disbale DDE

What is happening is that the shell is sending DDE messages to excel to
open a workbook, and that your excel instance is complying, which is
not what you want.

BTW this will fix DDE (explorer) but not COM automation. If you want to
disable COM/automation to other apps also also you need to subclass the
excel application. This will force excel to register itsself to COM
under another name. This however is quite tricky(only saw it done
correctly once.) and is only required when 2 different COM objects want
to try to use a running instance of excel instead of creating their
own. My advice is when you create excel _dictator_ apllications always
use your own excel instance, and block off DDE. If every XL dictator
app does correctly this there should be no issues;)

Rgrds,

DM Unseen
 
G

Guest

Thanks for your help, but now is the problem that if i open a excel file
manually there is nothing shown...it does not open the doubleclicked
file...the nice thing is it opens a new excel.exe but it should also open the
doubleclicked file... i have to go File-> Open to select a file...

is there no other way to get excel to make a new instance? or can i tell an
excel.exe process to be protected so that no other doubleclicked file is
opened in the same excel.exe process? i think the value "ignore other
application" is a bit to much, because the normal way to open an excel-file
is not working anymore...
 
D

DM Unseen

My reply seems gone but here I'll go again;)

It should work, I've tested it with Excel XP.

On how to use the enable in Tools->General ignore other applications:

This option is stored/updated in the registry upon closing of Excel,
but will work directly when set inside Excel.
Knowing this we can do the following:

1 on startup of Excel app we enable it. If it was already enabled, it
might have been done before startup, and other instances will have it
enabled as well! They wil still run on doubleclick, but will not load
the clicked file but show an error(in XL 2002). So we raise a warning
to the user that he/she might be in trouble!
On closing of the XL app, disable it (again), so it will not be stored
in the registry as enabled.

Presto, no issues, and the option is only local to our XL app!

other protections can only be archived with subclassing, which is way
too nasty to explain to innocent XL developers;)

DM Unseen

PS the option can be accesed in VBA with
Application.IgnoreRemoteRequests
 
D

DM Unseen

Protecting an excel instance = subclassing excel instance but I would
not go there if you can have it

Not opening the doubleclicked file is a bug, since at my end it opened
the double clicked file (Office XP) in a new instance!
I'm not sure why the doubleclicked file was not opened, but sometimes
some VBA startup code can wreck the DDE message qeue. Pls test if
doubleclicking works anyway with all XLA's installed.

How to use Tools->General ignore other applications

Enable this option through VBA when you launch the dictator addin!
Disable it when the dictator addin closes.

This will *not* interfere with other XL instances, because this option
will only be rembered on close, so all XL instances should be fine
unless the user "himself" has checked the box. Only *then* you should
raise a warning to the user! To be totally correct you would need to
inspect the registry to see if the box was checked before XL startup,
because then all XL instances will ignore DDE, and cause problems.

These precautions will actually keep this option local to your addin,
even if it is a global setting!

DM Unseen
 
G

Guest

Thanks again for your very nice description! It's nice to talk to someone who
realy knows what he's doing;-)

But i still didn't get the point...i hope you give me a last chance;-)

I have the following scenario:

1. I open an Excel-File with Automation from .net
2. I disable almost everything in that excel so the user has no possiblity
of changing the opened excel-file. I don't want him to save it at all (if you
know another way instead of disabling anything to do this I would apreciate
it very much)

3. Now the user doesn't work with that excel-file anymore (but leaves it
open) and want's to open an existing excel-file that is not accessed with
automation but by doubleclicking on it.

The problem is, the manually clicked excel-file is opened in the same
excel.exe process...but i need it to open correctly in a second
excel.exe...so with your help i was quite there...only that the manually
clicked excel-file did not open in this new excel.exe instance...

I may be asking a stupid question cause i'm quite new to this, but is the
described scenario not possible to achive?

thanks for your help
m. ahrens
 
G

Guest

now i got it!! sorry for my slow reaction time!!

thanks a lot for your help!
you saved my day!
m.ahrens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top