Re: Open a new instance of Excel
Hi,
I have a similar case (but slightly different). I did a so-called mini-tool based on excel and VBA.
And I would need that this tool to be open in a separate session (as I also use to hide the app window and leave only a userform visible).
Thing is... user can have some other workbooks open prior to opening this one, so I cannot control DDE on each computer and I cannot even use the IgnoreRemoteRequests for each workbook.
So, my idea is (not yet completed in code so I will describe it in pseudo-code)
In my tool, there will be a check once the workbook willl open (using the workbook_open event)
This will check if the file is alone in the current excel session;
If alone, that means it has been already started as separate session or it is the first file open in excel.
In this case, using Application.IgnoreRemoteRequests = True will do the trick.
If not alone in that session, then... it means it is open in an existing instance (let's call it first session).
Save itself in a temporary copy - to a pre-established naming and location, slightly different than the usual filename.
(This will allow opening the usual file in a new session)
So, next is creating a new Excel instance where to open the original file (now available as it was saved under another name temporarily).
Then, close the current workbook (not touching other workbooks in the first session).
Another tricky part is that, once started alone in a session, the script should check for the pre-established naming and location and if exists... to delete that for future use. Or, the script can just overwrite that without prompting and then we can forget about this part.
I guess if trying to delete too early (before the initial file has closed itself) it will fail. So one can set a waiting time or delete that later on, triggered by another event (eg. Quit or Close the workbook).
What do you say? It is doable?