tags:

views:

106

answers:

2

I have the following piece of code in Visual C++ 2005 : :

class _Application:public COleDispatchDriver {....};

_Application excelApp;

excelApp.CreateDispatch((LPCTSTR)_T("Excel.Application")))

But the call to excelApp.CreateDispatch((LPCTSTR)_T("Excel.Application"))) returns a zero value indicating a failure .

Could you please tell me what could be the possible reason ?

PS : I copied the above piece of code from an another solution ( Visual C++ 2005) where this works perfectly fine on the same machine .

+1  A: 

I got the answer people :

I just had to call CoInitialize(0) before the above piece of code .

and then CoUninitialize() after all are done .

Cool it was ....

Rakesh Agarwal
Good work for writing in the answer when you found it.
Leon Bambrick
A: 

Thanks for providing the answer too.

Joseph Antony