Important: Please read the Qt Code of Conduct -

How to use Excel macros with parameters in Qt?

  • Hello boys and girls,

    I am traying to find out, how I can start a Excel macro with Qt and use parameters.

    At first I wrote a VBScript to open a Excel document and start this macro without parameters. Now I want a nice Qt application.

    Can someone tell me, how I can do some stuff with Qt:

    • update the sheets
    • save the Excel document
    • run a Excel macro with parameters
    • close Excle

    Here is my first try
    QAxObject *excel = new QAxObject("Excel.Application", this);
    QAxObject *workbooks = excel->querySubObject("Workbooks");
    workbooks->dynamicCall("Open (const QString&)", m_excelFile);
    excel->dynamicCall("DisplayAlerts(Boolean)", true);
    excel->dynamicCall("Run (const QString&)", "Screenshot");
    workbooks->dynamicCall("Close", true);
    excel->dynamicCall("Quit", 0);

    PS: Thank you for your time and help. I am from Germany and that is the reason form my great english skills :)

Log in to reply