<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Replacing Field values in Word Document QAxObject]]></title><description><![CDATA[<p dir="auto">Dear all,</p>
<p dir="auto">I'm really new to QT and I was tasked to update some field values in word document programmatically, currently I can replace text from word document fine, but when that field value is inside an object (table or anything) it's not working, my code is:</p>
<pre><code>        QString     outFile("D:\\#test files\\output.docx");
        QString     inFile1("D:\\#test files\\input.docx");
        QAxObject   axObject("Word.Application");
        QAxObject* documents = axObject.querySubObject("Documents");
        QAxObject* document = documents-&gt;querySubObject("Open(const QString&amp;, bool)", inFile1, true);
        QAxObject* selection = axObject.querySubObject("Selection");
        auto find = selection-&gt;querySubObject("Find");
        QString sOld = "${name}";
        QString sNew = "Ibrahim";
        bool bMatchCase = false;
        bool bMatchWholeWord = false;
        bool bMatchWildCards = false;
        bool bReplaceAll = true;
        QVariantList vl = { sOld, bMatchCase, bMatchWholeWord, bMatchWildCards, false, false, true, 1, false, sNew, bReplaceAll ? "2" : "1" };
        find-&gt;dynamicCall("Execute(QString,bool,bool,bool,bool,bool,bool,int,bool,QString,int)", vl);
        document-&gt;dynamicCall("SaveAs(const QString&amp;)", outFile);
        document-&gt;dynamicCall("Close()");
        axObject.dynamicCall("Quit()");
</code></pre>
<p dir="auto">If you can help it would be awesome :)</p>
<p dir="auto">Best regards,<br />
Ibrahim</p>
]]></description><link>https://forum.qt.io/topic/120921/replacing-field-values-in-word-document-qaxobject</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 18:44:13 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/120921.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 17 Nov 2020 12:00:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Replacing Field values in Word Document QAxObject on Tue, 17 Nov 2020 12:23:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ivasija-evonem">@<bdi>ivasija-evonem</bdi></a><br />
You may not a useful answer here, as I don't think this has anything to do with Qt/<code>QAxObject</code>.  You need to either read up in what you need to do in Word to achieve this, or try your code from a Word VBA macro/recording from Word, to determine what really needs to be done to find the items correctly.</p>
]]></description><link>https://forum.qt.io/post/627795</link><guid isPermaLink="true">https://forum.qt.io/post/627795</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 17 Nov 2020 12:23:01 GMT</pubDate></item></channel></rss>