Board index » cppbuilder » Pointers using TLB import files

Pointers using TLB import files

I would like to use the COM objects that MS Office provides.  I  am
importing the type library to my program so that Borland
makes the wrapper header and function calls to the COM objects.  I have no
problem creating an instance of the objects as a
new object.  My problem is that I can not pass the pointer to to an existing
COM object to a new object.  The following is an example.

void __fastcall TForm1::Button1Click(TObject *Sender)
{
_Workbook *wbWorkBook;

appExcel = CoApplication::Create();   // this works fine
appExcel->get_ActiveWorkbook(wbWorkBook);  //I get the following error

Quote
}//type mismatch in parameter 'RHS' in call to

'__stdcallExcel_tlb::_Application::get_ActiveWorkbook(Excel_tlb::_Workbook**
)'

When I try this I get an access violation when calling this function.

 void __fastcall TForm1::Button1Click(TObject *Sender)
{
_Workbook *wbWorkBook;

appExcel = CoApplication::Create();   //no problems
appExcel->get_ActiveWorkbook(&wbWorkBook); //I have a feeling this is not
doing what I want it to do.
wbWorkBook->Activate(0);  //run time error:  access violation.

Quote
}

 

Re:Pointers using TLB import files


Hello,

http://www.brickhouse.com

Quote
David Suess wrote in message <72kd9o$k...@forums.borland.com>...
>When I try this I get an access violation when calling this function.

> void __fastcall TForm1::Button1Click(TObject *Sender)
>{
>_Workbook *wbWorkBook;

>appExcel = CoApplication::Create();   //no problems
>appExcel->get_ActiveWorkbook(&wbWorkBook); //I have a feeling this is not
>doing what I want it to do.
>wbWorkBook->Activate(0);  //run time error:  access violation.
>}

Are you sure wbWorkBook is non-NULL?

--
Binh Ly
Brickhouse Data Systems, Inc.

Other Threads