Need to open an instance of excel from C++ code and then attach to it

My software is an excel plug-in. I need to do some unit-testing through Visual Studio ( debug mode ). We are using the C++ unit test framework embedded within Visual Studio.

Now, in my C++ test-code, when I open excel ( e.g. through shellexecute ), Excel opens up in a separate process and hence, I am not able to debug it in my debug process in Visual Studio. Moroever, related code gets executed in that process and not in my visual studio instance.

How do I attach to the excel programatically so that I can follow the behaviour in the debug mode of visual studio ?

It's a unit-test scenario and hence, we are trying to do everything with least manual intervention.

Regards,
Raj Abhishek
First of all you're in the wrong forum. The short answer is you should be able to find your answer on the MSDN site.
@ koothkeeper: That is a terrible answer.

@ OP: What kind of errors are you looking for? Is it an option to just dump the data to a text file or something? If you're plug-in is crashing Excel then the data will be in Event Viewer.
@koothkeeper. Whats the point of saying "first of all" if there is no "second"?
@Computergeek01: Sorry for the terrible answer. I just assumed someone taking on debugging with Visual Studio would have the common sense to choose the appropriate forum. Buy hey, thanks for using italics: That shows you know how to emphasize without using bold -- quite the step up!

@TarikNeaj: I had my seconds -- I can't help it if you didn't find any.
Guys ... This is not about visual studio .. I am using visual studio for my development .. that's all .. and I know how to attach to a process and then debug using visual studio ..

You can say I want to do the same thing from C++ code directly. Open excel from my unit-test code but in the same process, so that my add-in code is also run in the same process and I am able to test it.
Unless you have the source, it won't make a lot of sense. If you can understand assembler, then you should be able to attach to it.
Some suggested me to use the Microsoft Interop.Excel.dl ... https://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.aspx

I could see we can have _Application, _Workbook objects there ... If I create a _workbook object in my test-code, will my add-in be loaded too, and the corresponding code run ??? Not tried yet.
If you're going to go that route then I can say from experience that it's much easier to use Interop with VBA then it is with C. Otherwise, at a glance at least, it looks like a valid solution to your issue.
Topic archived. No new replies allowed.