OpenOffice Calc macro: set column width

sub DailyProfit
rem ------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

 oCalcDoc = ThisComponent 
 oSheets = oCalcDoc.getSheets()
 oSheets.removeByName( "DProfit" )
 SetColWidth( 1, 2.5, oSheet )
 SetColWidth( 2, .5, oSheet )
end sub
sub SetColWidth( col as integer, nchs as single, oSheet as object )
 dim w as single
 w = nchs * 2540
 ' get column
 oColumn = oSheet.getColumns.getByIndex( col )
 ' column width (in 100ths of mm)
 oColumn.Width = w
end sub

Reference:

 




Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>