Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-79167

QAxObject has issue interacting with Office 365

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P3: Somewhat important
    • Resolution: Incomplete
    • 5.11.2
    • None
    • ActiveX Support
    • None
    • Windows 10 64 bit
    • Windows

    Description

      Using QAxObjects to interact with excel as following: 

          QAxObject* pApp = new QAxObject("Excel.Application", 0);
          pDoc = pApp->querySubObject("Workbooks");
          pContent = pDoc->querySubObject("Open(QString)", QDir::toNativeSeparators(path));
          pVBProject=pContent->querySubObject("VBproject");
          pVBComponent=pVBProject->querySubObject("VBComponents");
          int macroCount = pVBComponent->property("Count").toInt();
          for (int i=1; i<=macroCount; i++) {
              qDebug()<<QString("Module #%1 of #%2").arg(i ).arg(pVBComponent->property("Count").toInt()));
              QAxObject* module = pVBComponent->querySubObject("Item(int)", i); 
              if(module==nullptr) continue; 
              qDebug()<<QString("Module \"%1\"").arg(module->property("Name").toString());
              QAxObject* codeModule = module->querySubObject("CodeModule"); 
              if(codeModule==nullptr) continue;
              int lineCount=codeModule->property("CountOfLines").toInt(); //<--pVBComponent>property("Count").toInt() will return 0 if placed after this point, only happen for Office 365, what is wrong? 
              qDebug()<<QString("%1 lines").arg(lineCount); 
              }

      Everything works as expected in Office 2016 and etc, but not in Office 365, where I get:

      Module #1 of #7
      Module "Module1"
      0 lines
      Module #2 of #0
      Module #3 of #0
      Module #4 of #0
      Module #5 of #0
      Module #6 of #0
      Module #7 of #0

      After some poking, pVBComponent is actually lost (? ) in the lineCount call as indicated above in the first loop. This only happens with Office 365. What is wrong? Thanks.

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            yep p p
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes