- wxAutomationObject excelObject, rangeObject;
- if (!excelObject.GetInstance(_T("Excel.Application")))
+ // Ensure that Excel is visible
+ if (!excelObject.PutProperty(wxT("Visible"), true))
+ {
+ wxLogError(wxT("Could not make Excel object visible"));
+ }
+ const wxVariant workbooksCountVariant = excelObject.GetProperty(wxT("Workbooks.Count"));
+ if (workbooksCountVariant.IsNull())
+ {
+ wxLogError(wxT("Could not get workbooks count"));
+ return;
+ }
+ const long workbooksCount = workbooksCountVariant;
+ if (workbooksCount == 0)