Export Data to Excel File
I want to export data to Excel File and I wrote codes below
void __fastcall TMainForm::ToolButton2Click(ToolButton2)
{
Variant ExApp,Wbs,Wb,Ws;
try
{
ExApp=CreateOleObject("Excel.App");
}
catch(...)
{
MessageDlg("Excel can not run normally",mtError,TMsgDlgButtons()<<mbOK,0);
}
* Wbs=ExApp.OlePropertyGet("WorkBooks");
Procedure Open("Open");
Wbs.Exec(Open<<sFileName);
ExApp.OlePropertySet("Visible",(Variant)true);
Wb=Wbs.OleFunction("Add");
Wb=ExApp.OlePropertyGet("ActiveWorkbook");
Ws=Wb.OlePropertyGet("ActiveSheet");
}
While the code runs to *, it shows me problems
"Project Export.exe raised exception class EAccessViolation with message
'Access Violation at address 004FD9B in module'Export.exe',Read of address 00000800'Process stopped. Use step or Run to continue"
I dont know whats matter with it, and pls help me to solve it. I am waiting on line.