Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Can the default value for OptimalWidth of a column be changed?

Using Libre Office 6.0.6.2(x64) on Windows 7.

If you think the answer to this is easy, you are probably not understanding the question.

How do you permanently change the default value for the optimal width of a column so that when a basic macro uses the instruction setPropertyValue("OptimalWidth", TRUE), 0.1 inches are not added to the column?

I have tried using a template where the default is not selected (in Format->Columns->Optimal Width...). When I then manually select the columns and set them to OptimalWidth, the 0.1 inch is not added. But when a basic macro is run and the columns set to OptimalWidth the 0.1 inch is added.

I have the below work around where I set the width to optimal, get that width, subtract ~ 0.1 inch (it works) but would like to know if there is a way to disable or remove the builtin default of adding 0.1 inches when the Basic instruction setPropertyValue("OptimalWidth", TRUE) is used?

oColumn = oSheet.getColumns.getByIndex(i)
oColumn.setPropertyValue("OptimalWidth", TRUE) 
oColumn.setPropertyValue("Width",(oColumn.getPropertyValue("Width")-180))

Can the default value for OptimalWidth of a column be changed?

Using Libre Office 6.0.6.2(x64) on Windows 7.

If you think the answer to this is easy, you are probably not understanding the question.

How do you permanently change the default value for the optimal width of a column so that when a basic macro uses the instruction setPropertyValue("OptimalWidth", TRUE), 0.1 inches are not added to the column?

I have tried using a template where the default is not selected (in Format->Columns->Optimal Width...). When I then manually select the columns and set them to OptimalWidth, the 0.1 inch is not added. But when a basic macro is run and the columns set to OptimalWidth the 0.1 inch is added.

I have the below work around where I set the width to optimal, get that width, subtract ~ 0.1 inch (it works) but would like to know if there is a way to disable or remove the builtin default of adding 0.1 inches when the Basic instruction setPropertyValue("OptimalWidth", TRUE) is used?

oColumn = oSheet.getColumns.getByIndex(i)
oColumn.setPropertyValue("OptimalWidth", TRUE) 
oColumn.setPropertyValue("Width",(oColumn.getPropertyValue("Width")-180))

The answer by Mike fully answers my question. There is no way to change the default optimal width from within a Basic macro run from My Macros & Dialogs. I will use the workaround.

WRT 200 being the correct calculation: also correct; however, this results in the column being too narrow. 188 should give an exact fit (if I did the math right) but I used 180 just to be sure.