Get all running Excel
-
I have multiple excel.exe running on my system . When I called GetActiveObject() method then I am able to get only the one excel.exe not all . So please tell me how can I get all the running excel.exe
Trioum
from what Ive seen GetActiveObject() is only going to get one instance. If you are looking for a particular instance, you could try looping :- GetActiveObject() Is This instance what Im looking for ? If No CLose the excel instance repeat until you find the excel instance you want I was thinking that you could enumerate windows with Excel in the title, somehow close the ones you dont want (assuming you can detect the one you do want by the window title), then do a GetActiveObject() sorry .. maybe someone else has a better idea
-
from what Ive seen GetActiveObject() is only going to get one instance. If you are looking for a particular instance, you could try looping :- GetActiveObject() Is This instance what Im looking for ? If No CLose the excel instance repeat until you find the excel instance you want I was thinking that you could enumerate windows with Excel in the title, somehow close the ones you dont want (assuming you can detect the one you do want by the window title), then do a GetActiveObject() sorry .. maybe someone else has a better idea
-
No your idea is failed every time I got the same Excel. And I cannot close the running excel.exe
Trioum
well, good luck
-
No your idea is failed every time I got the same Excel. And I cannot close the running excel.exe
Trioum
btw how did you implement either of my ideas ? and
trioum wrote:
And I cannot close the running excel.exe
why not ? obviously if you cant close any excel instance you dont want then you'll never get to the one you do want.. what do you have so many zombie excel instances ? 'g'
-
btw how did you implement either of my ideas ? and
trioum wrote:
And I cannot close the running excel.exe
why not ? obviously if you cant close any excel instance you dont want then you'll never get to the one you do want.. what do you have so many zombie excel instances ? 'g'
-
do you know if GetActiveObject() returns a reference to the Excel instance that 'has focus' or 'is currently active' ? If that were the case, AND you could distinguish which excel instance was which by the Window title, then you could build a workable solution a) enumerate all the excel instances and look at their window titles b) force the instance you want (by window title) to come to the front ie give it focus c) then do a GetActive Object somehow I dont think its that easy - the GetActiveObject may have its own way of looking at the ROT or process table, not just the 'active excel instance' - thats confirmed by looking further : MS KB 238975 - http://support.microsoft.com/kb/238975[^] says "NOTE: If there are multiple instances of an automation server running at the same time, the GetActiveObject() API function returns the IDispatch pointer to the instance that was first running." So I dont think you're going to be able to do it :-(