Calc macro: how can I find the current column widths?

I am a beginner in LibreOffice Basic - In my spreadsheet’s content.xml, I see entries like:

<style:style style:name="co3" style:family="table-column">
  <style:table-column-properties fo:break-before="auto" style:column-width="22.38mm" />

which seems to tell me that the second column’s width is currently 22.38mm. How can I fetch such values in a Libreoffice Basic macro?


It is prudent to first test if the selection is a cell to avoid runtime errors, so to find the current column width you can do:

Sub Main

dim oSel

oSel = thiscomponent.currentselection

if oSel.supportsService("") then
	msgbox oSel.columns.getByIndex(0).width
end if

End Sub