I'm trying to implement a macro for setting columns to specified widths in Calc. Here's what I've done:
Code: Select all
sub SetColWidth( col as integer, nchs as single, oSheet as object )
Static oColumn As Object
dim w as single
w = nchs * 2540
' get column
oColumn = oSheet.getColumns.getByIndex( col )
' column width (in 100ths of mm)
oColumn.setPropertyValue("Width", w)
end sub
Sub FormatColumns
static oSheet as object, oDoc As Object
oDoc = ThisComponent
oSheet = ThisComponent.getCurrentController.getActiveSheet
SetColWidth( 0, 1.5, oSheet )
SetColWidth( 1, .33, oSheet )
SetColWidth( 2, .33, oSheet )
SetColWidth( 3, .75, oSheet )
SetColWidth( 4, .75, oSheet )
SetColWidth( 5, .75, oSheet )
SetColWidth( 6, 2.75, oSheet )
End Sub
Jay