Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How shall I use VB function parameters in Qt call?



  • This VB function returnes address in A1-format.

    mc.Address()
    

    If I whant R1C1-format I shall to set "ReferenceStyle" to "xlR1C1".
    Like this

    mc.Address(true, true, xlR1C1)
    

    or this

    mc.Address(ReferenceStyle:=xlR1C1)
    

    In Qt this code is working:

    cell->dynamicCall("Address(true, true, xlR1C1)").toString();
    

    But this code is not (format address still "A1"):

    cell->dynamicCall("Address(ReferenceStyle:=xlR1C1)").toString();
    

    How shall I use VB function parameters in Qt call?



  • Hi, I don't think Qt supports VB named parameters (i.e. using "paramname := value") in the ->dynamicCall function, so you have to specify all the arguments :-(
    Instead of true you can say -1 (it's the same in VB/COM), so this also works:

    cell->dynamicCall("Address(-1,-1,xlR1C1)").toString();
    


  • Unbelievable...



  • @flammmable
    What's unbelievable? That Qt --- a platform independent library/toolkit --- does not support named parameters when allowing you to use VBA to communicate with MS Excel...?



  • OP reporting the results of the invistigation )

    Actualy, I need to use Range.Find with whole match.
    In VB it will be like this

    cell = someRange.Find("something", LookAt:=xlWhole)
    

    In Qt it will be like this

    QAxObject* MainWindow::findCell(QAxObject* range, QString what) {
        QAxObject* firstCell;
    
        firstCell = range->querySubObject("Cells(1,1)");
        return range->querySubObject("Find(const QString&, " + 
                                          "const QVariant&," +
                                          "int, "            +
                                          "int)", 
                                     what, 
                                     firstCell->asVariant(), 
                                     -4163, 
                                     1);
    }
    
    ...
    
        cell = findCell(someRange, "something");
    

    By the way.
    Result: first part match

    range->querySubObject("Find(const QString&, const QVariant&)", what, firstCell->asVariant());
    

    Result: still first part match

    range->querySubObject("Find(const QString&, const QVariant&,  xlValues, xlWhole)", what, firstCell->asVariant());
    

    Result: still first part match

    range->querySubObject("Find(const QString&, const QVariant&, -4163, 1)", what, firstCell->asVariant());
    

    Result: NULL

    range->querySubObject("Find(const QString&, const QVariant&, const QString&, const QString&)", what, firstCell->asVariant(), "xlValues", "xlWhole"))
    

    Result: NULL

    range->querySubObject("Find(const QString&, const QVariant&, int, int)", what, firstCell->asVariant(), -1, 1);
    

Log in to reply