[Interest] QAxWidget and Winword

Petric Frank pfrank at gmx.de
Fri Feb 14 18:28:13 CET 2014


Hello,

i use QAxWidget/QAxObject to automate a mailmerge process.

The Mailmerge works well, but at end i find three Winword.exe processes in the 
task manager left over.
A subsequent run adds 3 additional Winword processes and so on. At the end i 
get an interval error dialog box from Winword.

This is the (shortend) code:
-------------------- cut -----------------------
// connect / startup Winword
QAxWidget * fApplication = new QAxWidget;
fApplication->setControl ("Word.Application");

// load template
QAxObject * documents = fApplication->querySubObject ("Documents");
QList<QVariant> params;
params << templateFile << false << false << false << "" << "" << false;
QAxObject * doc = documents->querySubObject ("Open(const QVariant&,const 
QVariant&,const QVariant&,const QVariant&,const QVariant&,const 
QVariant&,const QVariant&)", params);

// get mailmerge handle
QAxObject * merge = doc->querySubObject ("MailMerge");
QVariant connection (QString ("TABLE %1").arg (sheetName));
params.clear ();
params << excelFile << 0 << false << true << true << false << "" << "" << 
false << "" << "" << connection << "" << "" << false << 8;
merge->dynamicCall ("OpenDataSource (const QVariant&,const QVariant&,const 
QVariant&,const QVariant&,const QVariant&,const QVariant&,const 
QVariant&,const QVariant&,const QVariant&,const QVariant&,const 
QVariant&,const QVariant&,const QVariant&,const QVariant&,const 
QVariant&,const QVariant&)", params);

// start merge process
merge->dynamicCall ("Destination", 0); // = wdSendToNewDocument
merge->dynamicCall ("Execute ()");

// close template file
doc->dynamicCall ("Close (0)");

// make winword window visible to user
fApplication->dynamicCall ("Visible", true);

// disconnect from winword
fApplication->clear ();
-------------------- cut -----------------------

I expected only 1 remaining winword process (the on of the merged document).

It seems that the started word processes (1 * OLE + 2 * Documents) are 
remaning running. They do not know that they (1 OLE + 1 Document) can quit.

But even after closing the last open winword window manually the processes are 
still running.

What i am missing here ?

Any hints ?

Platform: Windows XP
Qt: 5.2.0 (MinGW)

kind regards
  Petric



More information about the Interest mailing list