[try Beta version]
Not logged in

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

Mar 25, 2015 at 1:44pm
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
Mar 25, 2015 at 3:31pm
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.
Mar 25, 2015 at 3:44pm
@ 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.
Mar 25, 2015 at 3:57pm
@koothkeeper. Whats the point of saying "first of all" if there is no "second"?
Mar 25, 2015 at 6:29pm
@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.
Mar 26, 2015 at 2:11pm
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.
Mar 26, 2015 at 3:15pm
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.
Apr 1, 2015 at 10:45am
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.
Apr 1, 2015 at 4:01pm
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.