sub Distribute_Rows_Evenly rem ---------------------------------------------------------------------- rem define variables dim document as object rem ---------------------------------------------------------------------- rem get access to the document document = ThisComponent controller = document.getCurrentController 'Get the current selection and check that part of a table has been selected sel = controller.getSelection() if sel.ImplementationName <> "SwXTextTableCursor" then exit sub selRng = sel.RangeName 'Extract the rows from the selection name (in the form 'C24:G15') pos = 0 ascZero = Asc("0") ascNine = Asc("9") do 'Look for the first number pos = pos + 1 ascVal = Asc(Mid(selRng, pos)) loop while (ascVal < ascZero or ascVal > ascNine) startRowNum = CLng(Mid(selRng, pos)) - 1 do 'Look for the second number pos = pos + 1 ascVal = Asc(Mid(selRng, pos)) loop while (ascVal < ascZero or ascVal > ascNine) endRowNum = CLng(Mid(selRng, pos)) - 1 'Early-out if only one row selected if startRowNum = endRowNum then exit sub 'Get the table vcurs = controller.getViewCursor() table = vcurs.TextTable rows = table.getRows() 'Add up all the row heights totalHeight = 0 for pos = startRowNum to endRowNum totalHeight = totalHeight + rows(pos).Height next 'Calculate the average row height aveHeight = totalHeight / (endRowNum - startRowNum + 1) 'Set all the row heights to the average for pos = startRowNum to endRowNum rows(pos).IsAutoHeight = False rows(pos).Height = aveHeight next end sub