Ask Your Question

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

asked 2015-10-11 21:15:20 +0200

wybodekker gravatar image

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?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-03-17 20:59:09.909607

1 Answer

Sort by » oldest newest most voted

answered 2015-10-12 09:23:39 +0200

pierre-yves samyn gravatar image


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


edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-10-11 21:15:20 +0200

Seen: 438 times

Last updated: Oct 12 '15