Page 1 of 1
[Solved] How to get the Width of the first column of a Table
Posted: Mon Dec 19, 2011 8:10 pm
by brunnerdan
Let's get a reference of a Table with the following code :
Code: Select all
myDocument = ThisComponent
myTable = myDocument.TextTables.getByName( "Table1" )
How can I get the width of the first
column in my table ?
Re: How to get the Width of the first column of a Table ?
Posted: Mon Dec 19, 2011 8:27 pm
by JohnSUN-Pensioner
Code: Select all
Sub WhereIsColumnsDelimiters(Optional numTable%)
Dim oTextTables As Object
Dim oTextTable As Object
Dim oColumns, i%
If IsMissing(numTable) Then numTable = 0
oTextTables = ThisComponent.getTextTables()
If oTextTables.getCount() = 0 Then Exit Sub
oTextTable = oTextTables.getByIndex(numTable)
oColumns = oTextTable.getPropertyValue("TableColumnSeparators")
For i = 0 To UBound(oColumns)
print " " & (i+1) & " column finished at " & oColumns(i).Position
Next i
End Sub
Re: How to get the Width of the first column of a Table ?
Posted: Tue Dec 20, 2011 3:34 pm
by brunnerdan
Thanks, it seems to work. But in which unit the oColumns(i).Position is returned ? How can I convert the value returned to "centimeters" ?
Re: How to get the Width of the first column of a Table ?
Posted: Tue Dec 20, 2011 3:49 pm
by JohnSUN-Pensioner
Oh, sorry! See
here
"The real width of a table depends on the environment (page style and number of text columns at the table's position, alignment, and left and right margins). For that reason, the table
column separator does not contain metric values for the
column widths. The values are relative to the value of the property
TextTable::TableColumnRelativeSum."
But you can try
this topic
Re: How to get the Width of the first column of a Table ?
Posted: Wed Dec 21, 2011 9:40 am
by brunnerdan
Great, thanks !