Issue
I am not proficient at VBA but need to use the documentation from microsoft the documentation form msdn to retrieve the number of pages in a word document.I have tried things like in the snippet below:
mWordDoc=new CustomQAxWidget("d:\\gakwandi.docx",0);
QAxObject* selection = mWordDoc->querySubObject( "Selection" );
QAxObject* pageNumbers = selection ->querySubObject( "PageNumbers" );
int numberOfPages = pageNumbers->property("Count").toInt();
But I am getting errors like QAxBase::dynamicCallHelper: PageNumbers: No such property in d:\gakwandi.docx [unknown] Candidates are:…..which suggests that I am somehow getting the syntax wrong somewhere.I was hopping someone more experienced with windows programming would hepl point out what I might be doing wrong.
Thanks.
Solution
I as able to put a piece of code together to get what I wanted.Just leaving it here in case somebody else needs to do the same.Thanks again KazJaw.Your input was really helpful.
QAxObject* word = new QAxObject("Word.Application", this);
//2.OPEN THE DOCUMENT
QAxObject* doc = word->querySubObject("Documents");
doc->dynamicCall("Open(QVariant)", "d:\\gakwaya11.docx");
doc->setProperty("Visible",false);
//3.GET TO THE CONTENTS
QAxObject * activeDocument=word->querySubObject("ActiveDocument");
QAxObject * content=activeDocument->querySubObject("Content");
int mNumberOfPages = content->dynamicCall("Information(wdNumberOfPagesInDocument)").toInt();
//doc->dynamicCall("SaveAs (const QString&)", QString("d:\\karamage.docx"));
doc->dynamicCall("Close (boolean)", false);
word->dynamicCall("Quit (void)");
Answered By – musimbate
Answer Checked By – Senaida (BugsFixing Volunteer)