I would like to format an Microsoft Excel 2010 cell comment (e.g. change font, boldness, ..) using Qt 5.
I can add an comment to a cell using the following code:
QAxObject* cellRange = m_activeWorksheet->querySubObject("Cells(int, int)", row, col);
cellRange->dynamicCall("AddComment(const QVariant&)", comment);
I am also able to set the AutoSize property for the cell comment:
QAxObject* axComment = cellRange->querySubObject("Comment");
QAxObject* shape = axComment->querySubObject("Shape");
shape->querySubObject("TextFrame")->setProperty("AutoSize", autosize);
But I am not able to change "deeper" comment properties, e.g. TextFrame.Characters.Font.Bold.
After setting the cell comment, the command
shape->querySubObject("TextFrame")
returns a non-zero pointer, but
shape->querySubObject("TextFrame")->querySubObject("Characters")
returns NULL.
How do I format the cell comments using QAxObject
?
Is there a description of the properties/subObjects for the different QAxObject
s
accessible by QAxObject
?
The following code does not have any effect:
shape->setProperty("AutoShapeType", 5);
Probably the problem is that TextFrame does not have property Characters
. Instead it has method Characters
, but it full signature is
Characters(Start, Length)
Qt docs says that you should specify full signature, so you should probably query value with
shape->querySubObject("TextFrame")->querySubObject("Characters(Start,Length)")
You cannot set AutoShapeType
to 5
. AutoShapeType
is of type MsoAutoShapeType and aonly specified values are allowed.