Question

I need to get current page in my document, with set range. I found that it is possible to do by:

Range.Information(wdActiveEndPageNumber)     //example in C#

but i have problem with that. In documentation, information is visible as property. So when i use

QString number = myRange->property("Information(wdActiveEndPageNumber)").toString()

i'm getting nothing. I also tried dynamicCall, but either doesn't work. Simple properties as Text or Start works perfectly fine, but i have no idea what to do with these enumerations.

Whole code:

QAxObject *word, *doc;
word = new QAxObject("Word.Application", this);
word->setProperty("DisplayAlerts", false);
word->setProperty("Visible", true);
doc = word->querySubObject("Documents");
doc->dynamicCall("Open(const QString&)", "path to file");
QAxObject *act = word->querySubObject("ActiveDocument");
QAxObject *next = act->querySubObject("Content");
next->dynamicCall("Select()");
next->dynamicCall("Copy()");
QClipboard *clip = QApplication::clipboard();
myTextEdit->setText(clip->text());
QString number = next->property("Information(3)").toString();
QMessageBox::information(this, tr("cos"), tr("%1").arg(number)); //here i need to know how many pages i've got
Was it helpful?

Solution

Okay, after much research, I found that there is no possibility yet to take value from Information enum. Maybe in future version of Qt, but nowadays I had to create library in Visual Basic and invoke functions from C++ code.

OTHER TIPS

Just found a really cool answer to this question here: http://www.qtforum.org/article/31970/how-do-i-get-use-the-ienumerable-interface-in-qt.html

Here the answer again. With returnList containing your enum..

QAxObject *enum1 = returnList->querySubObject("_NewEnum");
IEnumVARIANT* enumInterface; //to get this, include <windows.h>
enum1->queryInterface(IID_IEnumVARIANT, (void**)&enumInterface);
enumInterface->Reset(); //start at the beginning of the list.
for (int i=0;i<returnList->dynamicCall("Count").toInt();i++)
{
    VARIANT *theItem;
    enumInterface->Next(1,theItem,NULL);
    QAxObject *item = new QAxObject((IUnknown *)theItem->punkVal);
    qDebug() << item->dynamicCall("Caption");
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top