0

I am struggling with connecting to already running Excel instance (it's opened automatically from different program). When I am trying to use GetObject(,"Excel.Application") I am getting an error "Cannot create activex component" (actually it's 'ActiveX-Komponente kann nicht erstellt werden' in German).

Is there any way to connenct to Excel directly with process ID or some other way to do it without getting this error?

RobRaj
  • 43
  • 2
  • 6
  • Does this answer your question? [Accessing an open Excel Workbook in C#](https://stackoverflow.com/questions/6682678/accessing-an-open-excel-workbook-in-c-sharp) – Jesse Jun 23 '22 at 22:06
  • Unfortunately not really as I am getting 'ActiveX-Komponente kann nicht erstellt werden' error whenever I am trying to use GetObject like I described – RobRaj Jun 24 '22 at 07:28
  • Is Excel running? Is it running in the same security context? – user18521918 Jun 24 '22 at 08:04
  • @RobRaj The accepted answer to that question says to use `GetActiveObject` not `GetObject`. `GetObject` creates a new instance whereas `GetActiveObject` does not. – Jesse Jun 24 '22 at 08:09
  • That is not true. As called by the questioner `GetObject` does `CLSIDFromProgID` then `GetActiveObject` on class ID then `QueryInterface` to get IDispatch interface. From October 2001 MSDN. – user18521918 Jun 24 '22 at 09:07

0 Answers0