Question

Hello could someone please help me with the following: I want to center the text in a scalc open office spreadsheet cell via Delphi and the OOoTools toolkit.

The following code does not work:

sRange := '$A$3:$A$3';
ooParams := CreateUnoStruct('com.sun.star.beans.PropertyValue', 1);
ooParams[0].Name  := 'ToPoint';
ooParams[0].Value := sRange;
execDispatch('.uno:GoToCell', ooParams);

ooParams := CreateUnoStruct('com.sun.star.beans.PropertyValue', 1);
ooParams[0].Name  := 'HorizontalJustification';
ooParams[0].Value := 'com.sun.star.table.CellHoriJustify.CENTER';
execDispatch('.uno:HorizontalJustification', ooParams);

Has someone any idea why not? Thanks Ad

Was it helpful?

Solution

It seems that HorizontalJustification needs an enumvalue, but you're giving a string. You have to lookup the value of com.sun.star.table.CellHoriJustify.CENTER and fill your ooParams[0].Value with it.

Here is a way to lookup an enumvalue: http://www.oooforum.org/forum/viewtopic.phtml?t=16383

In your case com.sun.star.table.CellHoriJustify.CENTER equals 2, so you need:

ooParams[0].Name  := 'HorizontalJustification';
ooParams[0].Value := 2;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top