Macro - Change Column Text Alignment

I’m trying to change the alignment of all columns to left and so far I was unable to archieve that.
I tried the following:

oColumn.setPropertyValue("AlignLeft", true)
oColumn.Align = 1
oCell.setPropertyValue("AlignLeft", true)
oCell.Align = 1

Code snippet:

'Find the last used column'
oCellCursor.gotoEndOfUsedArea(True)
oCellRangeAddress = oCellCursor.getRangeAddress()
lEndColumn = oCellRangeAddress.EndColumn

for lColumnNumber  = lEndColumn to 1 step -1
	oCell = oSheet.getCellByPosition(lColumnNumber, 0)
	oColumn = oSheet.Columns.getByIndex(lColumnNumber)
	oColumn.setPropertyValue("AlignLeft", true)
next lColumnNumber

What about just

oCellCursor.gotoEndOfUsedArea(True)
oCellCursor.HoriJustify = com.sun.star.table.CellHoriJustify.LEFT
1 Like

That works, thanks. I was trying to implement it in the existing loop.