Trouble with QAxObject
-
Good day every one.
I have some trouble with QAxObject’s initialization. The programm must read a .doc file, which why i use QAxObject and compare this file with some StringList. But i don’t understand whats goin on, when i try simply open my file. I look up some code examples, but they give me ERROR-Segmentation fault. Here it is:
@QAxObject* docA = Doc->querySubObject("ActiveDocument()");
QAxObject* words = docA->querySubObject("Words()");
@
Here is full code:@void Dialog::WorkWithWord(QString &fileName)
{
QAxObject* Word = new QAxObject("Word.Application",this);
QAxObject* Doc = Word->querySubObject("Documents");
Word->dynamicCall("SetVisible(bool)", false);
Doc->dynamicCall("Open(QString&)", QString(fileName).replace("/", "\"));
QAxObject* docA = Doc->querySubObject("ActiveDocument()");
QAxObject* words = docA->querySubObject("Words()");
QString textResult, searchString;
char *found =NULL;
int count = 0;
int countWord = words->dynamicCall("Count()").toInt();for (int a=1;a<=countWord;a++) { textResult.append(words->querySubObject("Item(int)",a)->dynamicCall("Text()").toString()); }
ui->plainTextEdit->appendPlainText(textResult);
for (int x = 0; x < rowOfSignature.size(); ++x)
{
searchString = rowOfSignature[x];
found = strstr(textResult.toLocal8Bit().data(),searchString.toLocal8Bit().data());
if (found)
count++;
}
if (count>=3)
ui->textEdit_yes->append(fileName);
else ui->textEdit_no->append(fileName);
Doc->querySubObject("ActiveDocument")->dynamicCall("Close()");
Word->dynamicCall("Quit()");delete docA;
delete Doc;
delete words;
}@And that’s all for now.
Many thank in advance for any attention to this problem.