我正在研究一些适用于表格的 LibreOffice 宏,特别是将每列和行的宽度和高度设置为 0.85 厘米(0.335 英寸)。
在 MS Office 中,这很简单,只需选择表格并在宏中包含:
Selection.Rows.Height = CentimetersToPoints(0.85)
Selection.Columns.PreferredWidth = CentimetersToPoints(0.85)
LibreOffice 4.1 中没有这样的东西。看来每列/行都必须单独调整。有两种方法可以做到这一点:
迭代所有列/行并调整每列/行
将第一列/行调整为一些仔细计算的宽度/高度,然后调用均匀分布列/行
为了了解代码,我尝试使用宏记录器并浏览了表 |表属性并进行了修改,直到表看起来不错,但我所做的大部分内容都没有记录在宏中。
有人做过这样的事吗?
据我所知,这是:
sub Testing
dim tables as object
dim table as object
dim columns as object
dim column as object
dim index as integer
tables = ThisComponent.TextTables
if tables.Count > 0 then
table = tables.getByIndex(0)
columns = table.columns
table.Width = 850 * columns.Count '850 == 0.85 cm
for index = 0 to columns.Count - 1
column = columns.getByIndex(index)
'column is always NULL
'column.Width = 850
next
end if
end sub
指出的主要问题:
无法通过以下方式检索您要修改的实际表ThisComponent.CurrentSelection
,因此硬编码到索引 0 处的表
Any changes to the table don't seem to be reflected in the document, and no obvious way to re-render or refresh Seems to be working now! But still looking for a way to call the function to distribute columns evenly
columns.getByIndex
总是返回NULL
!,并且没有关于如何在 Basic 中使用列枚举类的文档
根据这项调查,建议against尝试使用 LibreOffice 4.1 Writer Basic 宏做任何富有成效的事情。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)