Ask Your Question
0

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" />
</style:style>

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
0

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

pierre-yves samyn gravatar image

Hi

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("com.sun.star.table.Cell") then
    msgbox oSel.columns.getByIndex(0).width
end if

End Sub

Regards

edit flag offensive delete link more

Question Tools

1 follower

Stats

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

Seen: 438 times

Last updated: Oct 12 '15