Hello everybody,
I started to read similar posts and I try to apply it but without success.
I need to open an excel file (that contains macro and use an INI file) into my application, embedding it into it.
I design a widget, and I promoted it to QAxWidget, after that I create this code to use the file:
Qt Code:
  1. ui->excel->setControl(srcfile);
  2.  
  3. //QAxObject * workbooks = ui->excel->querySubObject("WorkBooks");
  4. //workbooks->dynamicCall("Open (const QString&)", srcfile);
  5. //QAxObject * workbook = workbooks->querySubObject("ActiveWorkBook");
  6.  
  7. QAxObject * worksheet = ui->excel->querySubObject("Worksheets(1)");
  8. QAxObject * piva, * tipo, * data, * num, * scad, * tot;
  9.  
  10. //ui->excel->setProperty("Visible", false);
  11.  
  12. int i=0;
  13. while (qry->next()){
  14.  
  15. piva = worksheet->querySubObject("Cells(int,int)", i+2,1);
  16. tipo = worksheet->querySubObject("Cells(int,int)", i+2,3);
  17. data = worksheet->querySubObject("Cells(int,int)", i+2,4);
  18. num = worksheet->querySubObject("Cells(int,int)", i+2,5);
  19. scad = worksheet->querySubObject("Cells(int,int)", i+2,6);
  20. tot = worksheet->querySubObject("Cells(int,int)", i+2,7);
  21.  
  22.  
  23. piva->setProperty("Value",qry->value(0).toString().mid(2,-1).trimmed());
  24. if (qry->value(2).toString().startsWith('N'))
  25. tipo->setProperty("Value","N");
  26.  
  27. QDate dtData,dtScad;
  28. dtData=QDate::fromString(qry->value(1).toString(),"yyyyMMdd");
  29. dtScad=QDate::fromString(qry->value(4).toString(),"yyyyMMdd");
  30.  
  31. data->setProperty("Value",dtData.toString("dd/MM/yy"));
  32. //num->setProperty("Value",QString("%1 %2").arg(qry->value(2).toString()).arg(qry->value(3).toString()));
  33. num->setProperty("Value",qry->value(3).toString());
  34. scad->setProperty("Value",dtScad.toString("dd/MM/yy"));
  35.  
  36. tot->setProperty("Value",qry->value(5).toDouble());
  37.  
  38. i++;
  39.  
  40. }
  41.  
  42. ui->excel->setProperty("DisplayAlerts", false);
  43. ui->excel->dynamicCall("Run(QVariant)", "ckCampi");
To copy to clipboard, switch view to plain text mode 

When I enter the while I got Segmentation Fault error, and my application say QAxBase::dynamicCallHelper: Object does not support automation.

Where is the mistake?

I've also verified that If I run Macro that use INI file that not respond, as if the file was moved, the file is loaded in any qt system path? Which one? The ini file is correctly configured and positioned into the same path of excel file (as it should be!).

Have you got any ideas?

Thanks a lot for your time

Michele