connect til Excel
Jeg starter Excel op fra C++ Builder via COM:try
{
try
{
// connect to Excel
ExcelApplication1->Connect();
}
catch (Exception& exception)
{
MessageDlg("Excel may not be installed", mtError, TMsgDlgButtons() << mbYes, 0);
Abort;
}
ExcelApplication1->Visible[lcid] = True;
try
{
//Open
ExcelApplication1->Workbooks->Open(StringToOleStr(excelFile));
ExcelWorkbook1->ConnectTo(ExcelApplication1->ActiveWorkbook);
}
catch (Exception& exception)
{
//Create new
ExcelApplication1->Workbooks->Add(xlWBATWorksheet,lcid);
ExcelWorkbook1->ConnectTo(ExcelApplication1->ActiveWorkbook);
ExcelWorkbook1->SaveAs(excelFile,xlWorkbookNormal,"","",False,False,xlNoChange,
xlLocalSessionChanges,true,0,0,lcid);
}
Problemet er når jeg stopper applikationen, stopper Excel også - ligemeget om excel var startet før applikationen eller ej.
Er der mulighed for at connecte til Excel og disconnecte uden Excel stopper ?
//Tommy