Home
Automating OpenOffice: Optimizing Column Widths from a Macro

Start by reading the article "Automating OpenOffice: Customizing Key Strokes" which will show you how to set up an OpenOffice listener that captures key strokes; then change the keyPressed macro so that the columns are set to their optimal width whenever the return key is pressed:

function KeyHandler_keyPressed(oKeyEvent as new com.sun.star.awt.KeyHandler) as boolean
Dim oSheet
if oKeyEvent.keyCode = com.sun.star.awt.Key.RETURN then
	oSheet = thisComponent.getCurrentSelection.getSpreadSheet
	oSheet.getColumns.OptimalWidth = True
end if
end function

© MMVIII - Mark Alexander Bain