<< Click to Display Table of Contents >> Table (object) |
Access paths:
▪ Application à Documents à Item à Tables à Item
▪ Application à ActiveDocument à Tables à Item
1 Description
A Table object represents one individual table of the document and allows you to change its formatting.
An individual Table object exists for each table. If you add tables to a document or delete them, the respective Table objects will be created or deleted dynamically.
2 Access to the object
The individual Table objects can be accessed solely through enumerating the elements of the collection Tables. Each document has exactly one instance of this collection.
An example:
' Convert the first table of the document to text
tm.ActiveDocument.Tables.Item(1).ConvertToText
3 Properties, objects, collections and methods
Objects:
▪ Shading → Shading
▪ Cell → Cell
▪ Application → Application
▪ Parent → Tables
Collections:
▪ Rows → Rows
▪ Borders → Borders
Methods:
▪ ConvertToText
Shading (pointer to object)
Data type: Object
Returns the Shading object belonging to the table which represents the shading of the entire table.
Cell (pointer to object)
Data type: Object
Returns a Cell object that represents a table cell identified by a row and a column.
Syntax:
Cell(Row, Column)
Parameters:
Row (type: Long) specifies the row of the cell within the table. |
Column (type: Long) specifies the column of the cell within the table. |
Examples:
' Set the vertical alignment of cell B3 in the first table to "vertically centered"
With tm.ActiveDocument
.Tables(1).Cell(2,3).VerticalAlignment = tmCellVerticalAlignmentCenter
End With
' The same, but with a detour through the Rows collection
With tm.ActiveDocument
.Tables(1).Rows(2).Cells(3).VerticalAlignment = tmCellVerticalAlignmentCenter
End With
Application (pointer to object)
Data type: Object
Returns the Application object.
Parent (pointer to object)
Data type: Object
Returns the parent object, i.e. an object of the type Tables.
Rows (pointer to collection)
Data type: Object
Returns the Rows collection belonging to the table. You can use it to enumerate the individual rows in the table, allowing you to get or set their formatting.
Borders (pointer to collection)
Data type: Object
Returns the Borders collection representing the six border lines of the table. You can use this collection to retrieve and change the line settings (thickness, color, etc.).
ConvertToText (method)
Converts the table to text.
Syntax:
ConvertToText [Separator]
Parameters:
Separator (optional; type: either String or Long or TmTableFieldSeparator) indicates the character that should be used to separate the columns. You can specify either an arbitrary character or one of the following symbolic constants: |
tmSeparateByCommas = 0 ' Columns separated by commas
tmSeparateByParagraphs = 1 ' Columns separated by paragraphs
tmSeparateByTabs = 2 ' Columns separated by tabs
tmSeparateBySemicolons = 3 ' Columns separated by semicolons
If you omit this parameter, the value tmSeparateByTabs will be assumed. |
Return type:
Object (a Range object which represents the converted text) |
Example:
' Convert the first table in the document to text
tm.ActiveDocument.Tables.Item(1).ConvertToText tmSeparateByTabs