Here is a piece of code that expects to save a file as Excel format using wxAutomationObject.
When I launch the code (via menu), I receive a message box saying the following "Cannot start an instance of this class".
Code: Select all
wxAutomationObject ExcelObject;
wxString FileName = "test.xls";
ExcelObject.GetInstance(_T("Excel.Application"));
ExcelObject.CreateInstance("Excel.Application");
ExcelObject.PutProperty("Visible", true);
ExcelObject.CallMethod("Workbooks.Add");
ExcelObject.PutProperty("ActiveCell.Font.Bold", true);
ExcelObject.PutProperty("ActiveCell.Value", "test");
ExcelObject.PutProperty("DisplayAlerts", false);
ExcelObject.CallMethod("Workbooks.SaveAs", FileName);
ExcelObject.CallMethod("Workbooks.Close", true);
ExcelObject.CallMethod("Quit");
Does anyone have an idea ???
thanks a lot in advance
Antonio
Code: Select all
wxAutomationObject ExcelObject;
/*wxString test("Range(\"B5\").Activate");
//ExcelObject.GetInstance(_T("Excel.Application"));
ExcelObject.CreateInstance("Excel.Application");
ExcelObject.PutProperty("Visible", true);
//ExcelObject.CallMethod("Workbooks.Open", FileName);
ExcelObject.CallMethod("Workbooks.Add");
ExcelObject.PutProperty("ActiveCell.Font.Bold", true);
ExcelObject.PutProperty("ActiveCell.Value", "test");
ExcelObject.PutProperty("ActiveCell.Value", "tata");
ExcelObject.PutProperty("DisplayAlerts", false);
ExcelObject.CallMethod("Workbooks.SaveAs", FileName);
ExcelObject.CallMethod("Workbooks.Close", true);
//ExcelObject.CallMethod("Quit");
*/