Change Row Height and Column Width with a Macro

I wish to change the row heights and column widths of a spread sheet with a macro. I do not want to “Optimize” the row height, I want it to be a height I can set when the sheet is activated depending on criteria from another sheet. I know how to get the criteria. I only want to know how to change the height.

Sub FormatActiveCells
	RowHeight 10 ' use mm
	ColumnWidth 30 ' use mm
End Sub

Sub RowHeight ( xMM% ) ' use mm
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "RowHeight" : args2(0).Value = xMM * 100
CreateUnoService("com.sun.star.frame.DispatchHelper") _
.executeDispatch(ThisComponent.CurrentController _
.Frame, ".uno:RowHeight", "", 0, args2())
End Sub 'RowHeight


Sub ColumnWidth ( xMM% ) ' use mm
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "ColumnWidth" : args4(0).Value = xMM * 100
CreateUnoService("com.sun.star.frame.DispatchHelper") _
.executeDispatch(ThisComponent.CurrentController _
.Frame, ".uno:ColumnWidth", "", 0, args4())
End Sub 'ColumnWidth
	sheet = ThisComponent.CurrentController.ActiveSheet
	
	range = sheet.getCellRangeByName( "A5:A10" )
	range.Rows.Height = 1000
	
	range = sheet.getCellRangeByName( "A1:D5" )
	range.Columns.Width = 1000
2 Likes

This solution is so obvious I’m embarrassed by my question. Is there a source which lists the syntax for routine operations like this? The LidreOffice Guide does not seem to have this and the section on macros is woefully short on information.