Important: Please read the Qt Code of Conduct -

Use QAxScriptManager

  • Hello. I want to use QtScript in MS Word. I never did it and wrote an example:
    @QAxObject *WordApplication = new QAxObject("Word.Application", this);
    WordApplication->setProperty("Visible", true);
    QAxScriptManager *scriptManager = new QAxScriptManager(this);
    scriptManager->load("Documents.Add.TypeText("Hello :)")", "myscript", "JavaScript");@
    but it does not work. Please help me with errors and if there is - to give a piece of working code.

  • Hi,

    I never tried this, but one thing came into my mind:

    what is Document in line 5? You try to use VBScript from MS word inside Qt?
    Is there somewhere stated, that "QAxScriptManager": executes scripts inside the active X objects? I didn't find it.

    Additionally, to execute the script, you have to call: QAxScriptManager::call(...)

    As far as I understood, QAxScriptManager executes windows scripts, not application scripts...

  • Thank you for having responded to my question. I wanted to use ECMAScript in MS Word. I have never enjoyed QAxScriptManager class and did not find examples with him even in the developer blog Qt.

  • I think, it's not possible to access the word scripting this way. perhaps you can query QAxObject("Word.Application", this); for the scripting instance and start the scriptsv there, but not via QAxScriptManager.

  • I will do so:
    QAxObject(“Word.Application”, this);

    Thank you very much for your help:).

    Edit: fixed code layout; Andre

Log in to reply