Properties-all sizes are in twips
XLeft-Position of the left edge of the table
IsCentered-Set to True to center the table
Rows-Sets or returns the number of rows in the table
Columns-Sets or returns the number of columns in the table
Row-An Array of Rows (1 to Rows)
Column-An Array of columns (1 to Columns)
Column (I). xWidth-Width of the ith column
Cell-A 2-d Array of Cells (1 to Rows, 1 to Columns)
Cell (r, c). Contents-Sets or returns the contents of the cell
Methods
InsertTable (RTB As RichTextBox)-Inserts the table into the RichTextBox
At the currrent cursor position.
Code:
Http://www.applevb.com/RTFtable.zip
Example:
Option Explicit
Dim RTFtable As clsRTFtable
Private Declare Function LockWindowUpdate () Function LockWindowUpdate Lib "user32 "(_
ByVal hwndLock As Long _
) As Long
Private Sub commandementclick ()
Dim I As Integer
Set RTFtable = New clsRTFtable
'Stop flicker
Call LockWindowUpdate (RichTextBox1.hWnd)
For I = 1 To 5
With RTFtable
'Set the size of the table
. Columns = 3
. Rows = 2
'Fill the cells
'Row 1
. Cell (1, 1). Contents = "Row 1"
. Cell (1, 2). Contents = "Column2"
. Cell (1, 3). Contents = "Column3"
'Row 2
. Cell (2, 1). Contents = "Row2"
. Cell (2, 2). Contents = "R2C2"
. Cell (2, 3). Contents = "R2C3"
'Do we want to center it on the page?
. IsCentered = True
'Insert the table at the current cursor postion
. InsertTable RichTextBox1
End
Next I
Call LockWindowUpdate (0)
End Sub