How to add a table in MS Word Document using ActiveQt?



  • Hello everybody!
    I wrote a piece of code which should add a new table to my document but it doesn't work because of bad argument. the problem is with "range". How should I write it correctly?
    @
    void ChartWindow::makeWordDoc()
    {
    char const* const WordDocumentSaveAs = "SaveAs(QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&)";
    char const* const WordDocumentsAdd = "Add(QVariant&, QVariant&, WdNewDocumentType, QVariant&)";
    char const* const TablesAdd = "Add(QVariant&, QVariant&, QVariant&, QVariant&, QVariant&)";

    CoInitialize(NULL);
    
    QAxObject *wordApp = new QAxObject("Word.Application");
    wordApp->setProperty("Visible", true);
    QAxObject *wordDocs = wordApp->querySubObject("Documents");
    QAxObject *wordDoc = wordDocs->querySubObject(WordDocumentsAdd,"Normal",false,"wdNewBlankDocument",true);
    QAxObject *range = wordDoc->querySubObject( "Content()" );
    QAxObject *tables = wordDoc->querySubObject("Tables()");
    range->dynamicCall( "Expand(wdTable)" );
    range->dynamicCall( "Collapse(0)" );
    QAxObject *table = tables->querySubObject(TablesAdd, range->asVariant(),3,2,"wdWord9TableBehavior","wdAutoFitWindow");
    wordDoc->dynamicCall(WordDocumentSaveAs, "d:\\text.doc");
    

    }
    @
    Big thanks for any help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.