Getting the running instance from PID using COM
-
Is there any way to get the instance of EXCEL.EXE from Process ID using COM? Similar to GetActiveObject, is there any other thing through which we can get the instances of multiple EXCEL.EXE running in Task Manager? After getting handle to each EXCEL.EXE, I want to track all workbooks and sheets. I am using EXCEL automation to do this using C++. Getting all workbooks and sheets is done. But after getting PID of EXCEL.exe's , how to get that object? I am getting PID for each process using psapi.h. I think I am not asking a question, which I am not supposed to or I shouldn't ask.:confused::~ In C#.net we have BinkToMoniker to get the object. Is there any such thing in C++(unmanaged). Thanks in advance. Regards, KTT
-
Is there any way to get the instance of EXCEL.EXE from Process ID using COM? Similar to GetActiveObject, is there any other thing through which we can get the instances of multiple EXCEL.EXE running in Task Manager? After getting handle to each EXCEL.EXE, I want to track all workbooks and sheets. I am using EXCEL automation to do this using C++. Getting all workbooks and sheets is done. But after getting PID of EXCEL.exe's , how to get that object? I am getting PID for each process using psapi.h. I think I am not asking a question, which I am not supposed to or I shouldn't ask.:confused::~ In C#.net we have BinkToMoniker to get the object. Is there any such thing in C++(unmanaged). Thanks in advance. Regards, KTT
The following link should help you - How To Attach to a Running Instance of an Office Application[^] GetRunningObjectTable Function[^] IRunningObjectTable Interface[^]
«_Superman_» I love work. It gives me something to do between weekends.
Microsoft MVP (Visual C++) -
Is there any way to get the instance of EXCEL.EXE from Process ID using COM? Similar to GetActiveObject, is there any other thing through which we can get the instances of multiple EXCEL.EXE running in Task Manager? After getting handle to each EXCEL.EXE, I want to track all workbooks and sheets. I am using EXCEL automation to do this using C++. Getting all workbooks and sheets is done. But after getting PID of EXCEL.exe's , how to get that object? I am getting PID for each process using psapi.h. I think I am not asking a question, which I am not supposed to or I shouldn't ask.:confused::~ In C#.net we have BinkToMoniker to get the object. Is there any such thing in C++(unmanaged). Thanks in advance. Regards, KTT
-
KTTransfer wrote:
In C#.net we have BindToMoniker to get the object. Is there any such thing in C++(unmanaged).
AFAIK, BindToMoniker is an equivalent of C++ CoGetObject function.
With best wishes, Vita
Hey I tried all the ways but.....no Aim: To attach all the multiple processes of EXCEL.EXE's running in taskmanager and reading all sheets and workbooks using EXCEL automation. But using EXCEL automation only one instance of EXCEL we can connect using GetActiveObject. In above case only active instance is retrieved and even EXCEL.exe which is opened first is retrieved.But want to retrieve all workbooks and sheets in the running instances of EXCEL.EXE. Only way to differentiate between two EXCEL.EXE's running in taskmanager is PID. So want to connect the EXCEL instance using PID and then retrieving the workbooks and worksheets. IS there any way to get it, please give me clue. Thanks in Advance. Regards, KTTransfer.
-
Hey I tried all the ways but.....no Aim: To attach all the multiple processes of EXCEL.EXE's running in taskmanager and reading all sheets and workbooks using EXCEL automation. But using EXCEL automation only one instance of EXCEL we can connect using GetActiveObject. In above case only active instance is retrieved and even EXCEL.exe which is opened first is retrieved.But want to retrieve all workbooks and sheets in the running instances of EXCEL.EXE. Only way to differentiate between two EXCEL.EXE's running in taskmanager is PID. So want to connect the EXCEL instance using PID and then retrieving the workbooks and worksheets. IS there any way to get it, please give me clue. Thanks in Advance. Regards, KTTransfer.
-
KTTransfer wrote:
IS there any way to get it, please give me clue.
EXCEL registers each of his documents in ROT. Maybe, it's your case: you can enumerate all of EXCEL documents in ROT. PID is wrong way.
With best wishes, Vita
http://support.microsoft.com/default.aspx/kb/238975 In above site(as suggested by superman) ,it is clearly written that EXCEL registers only one instance of EXCEL.EXE in ROT. The other instance can only be retrieved if names of workbooks are known. Even in the same site, it is mentioned that for multiple instance refer the site: http://support.microsoft.com/kb/190985 But as per my requirement I need to track all excel.exe's running in processes using MFC(No gui, only exe)application but not setting anything in EXCEL as mentioned in above site. If you get any clue from above mentioned sites, please let me know. Thanks in advance. Regards, KTTransfer
-
http://support.microsoft.com/default.aspx/kb/238975 In above site(as suggested by superman) ,it is clearly written that EXCEL registers only one instance of EXCEL.EXE in ROT. The other instance can only be retrieved if names of workbooks are known. Even in the same site, it is mentioned that for multiple instance refer the site: http://support.microsoft.com/kb/190985 But as per my requirement I need to track all excel.exe's running in processes using MFC(No gui, only exe)application but not setting anything in EXCEL as mentioned in above site. If you get any clue from above mentioned sites, please let me know. Thanks in advance. Regards, KTTransfer
If you read the first page you link to, you have: However, because Office applications also register their documents in the ROT, you can successfully attach to other instances by iterating the ROT looking for a specific document, attaching to this document, and then getting the Application object from this document. For a code example of iterating the ROT and looking for a document name, click the article number below to view the article in the Microsoft Knowledge Base:... You don't even have to reference each individual instance as all documents (from all instances of excel) is in the ROT. If you need the application object for a document, it's also there via the document object.