1

I am trying to write to an open word document using activeQt. I am trying to activate my word document, but i cant get it to work.

I can do this in VBA very easily:

Documents("my.doc").Activate

but not in Qt, this is what i have tried:

wordApplication = new QAxObject("Word.Application");
doc = wordApplication->querySubObject("Documents()","my.doc");
doc->dynamicCall("Activate()");

Documents() is supposed to contain all the open word documents, but for me it is empty for some reason.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118

1 Answers1

1

I found the solution to my problem, by using the setControl function with the UUID for word I was able to access a word document that was already opened.

 QAxObject* wordApplication;
 QAxObject* doc;
 wordApplication = new QAxObject(this);
 wordApplication->setControl(("{000209FF-0000-0000-C000-000000000046}&"));
 doc = wordApplication->querySubObject("Documents()","my.doc");