Home > OS >  Use excel in VS2010 problem
Use excel in VS2010 problem

Time:11-02

Hello, I import excel in VS2010 related classes as follows, the import operation no problem of a class, in an error that execute the following code at the end of the sentence and error message: "GuangHong01. Exe of 0 x78fbe08c (mfc100d. DLL) with untreated exception: 0 xc0000005: while reading position 0 XFFFFFFFFFFFFFFFF access conflict"
What is wrong?

CApplication MyExcelApp;
CWorkbooks ExcelWbooks;
CWorkbook ExcelWbook;
CWorksheets ExcelWSheets;
CWorksheet ExcelWSheet;
CChart ExcelChart;
Try
{
MyExcelApp. CreateDispatch (" Excel Application ", NULL);
}
The catch (... )
{AfxMessageBox (" unable to start the Excel ");
return;
}
ExcelWbooks. AttachDispatch (MyExcelApp. Get_Workbooks (), TRUE);
ExcelWbook. AttachDispatch (ExcelWbooks. Add (_variant_t (" E: \ \ p6. XLS ")));
  • Related