TableCell object represent the attributes of a tabulation cell, i.e. all the attributes that can be modified using the EditTableCellDlg command.
TableCell object can be obtained from a text being edited using the GetTableCell function, e.g: dim objTableCell = Text.GetTableCell note that the cursor should be positioned inside an editable table for this method to work. |
Getting and setting properties
A TableCell object has a number of properties, each one corresponding to a cell attribute. Each one of these properties can be set - modifying the corresponding attribute - or queried - returning the value of the corresponding attribute. When setting values, remember that you have to call explicitly the SetTableRow command supplying modified object, e.g. Text.SetTableCell (objTableCell) When querying values, remember that these properties can also be 'without value'. This happens when the corresponding attribute has not been set, or it has multiple values, or it has been explicitly chosen as 'don't change' in a dialog. Attempts to query the value of a property that does not have a value causes a run-time error during the execution of the script. For each one of the properties there is a Boolean function that specifies if the corresponding property has a value. The name of these Boolean functions is the same of the properties prefixed with 'Has', so the Advance property holds the margin of the cell and the HasAdvance function returns true if Advance has a value. |
To reset local properties for the current row and let them be overridden by table properties, use Text.RemoveTableRowProp (0) or Text.RemoveTableRowProp (1) (parameter 0 means do not modify joined cells - if any, and 1 means do modify also joined cells). To reset local properties of entire table and let them be overridden by table properties, use Text.RemoveTableProp (0) or Text.RemoveTableProp (1) (parameter 0 means do not modify joined cells - if any, and 1 means do modify also joined cells). In the case of a TableCell object obtained from a text using the GetTableCell function, each attribute property has a value either if the text has no selection, or if the corresponding attribute has the same value in all the cells containing selected text, e.g.: dim objTableCell = Text.GetTableCell If Not objTableCell.HasAdvance Then MsgBox ("The selected cells have different top margins") Else MsgBox ("The selected cell(s) has a top margin of " & objTableCell.Advance(0)) End If The values that are assigned to attribute properties are validated: attempts to assign invalid values causes run-time errors, e.g. it is not possible to assign to the TopAdd property a negative value. |
To set fill color of all cells in a table, use CellColor and CellGray on the table level. To set them on the specific cells, use FillColorName and FillColorGray on the cell level, that supersede table level settings. |
On the cell level, you cannot set the border color, shade, dash, weight or position. For bottom border on the table level, use HRuleColor, HRuleGray, HRuleDash, HRuleWidth, HRuleInside, or on the row level use RuleColor, RuleGray, RuleWidth. For right border on the table level use VRuleColor, VRuleGray, VRuleDash, vRuleWidth, or on the column level with RuleColor, RuleGray, RuleWidth. To set left and top borders of the cells in the first column/first row, use ExtRuleColor, ExtRuleGray, ExtRuleDash, ExtRuleWidth. Same properties are used to set the right and bottom borders of the external cells, and if set, supersede the cell-level settings. On the cell level you can only turn the rules off with DrawHRule and DrawVRule. |