API provides the corresponding methods like UI to manipulate revision table.
- RevisionTables: the collection of revision table in a sheet. Its Add or Add2 method can create a new revision table.
- RevisionTable: the specific revision table. You can set its title, position and the styles of header of column or row, or even delete it.
- RevisionTableColumns: the collection of the columns. It supports to add a new column.
RevisionTableColumns.Add(
PropertyType As RevisionTablePropertyEnum,
[PropertySetId] As String,
[PropertyIdentifier] As Variant,
[TargetIndex] As Long,
[InsertBefore] As Boolean ) As RevisionTableColumn
RevisionTablePropertyEnum specifies the property type to associate with the column.
- RevisionTableColumn: the specific column. You can control the justification, title, even delete the column.
- RevisionTableRows: the collection of the rows. It supports to add a new row or custom row.
- RevisionTableRow: the specific row that can access the cell by RevisionTableRow.Item.
- RevisionTableCell : the specific cell of the row. it tells the value of the cell.
The following is a small code that demos how to create a new revision table and some kinds of columns.
Sub AddRevisionTable()
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oRTBs As RevisionTables
oRTBs = oDrawDoc.ActiveSheet.RevisionTables
Dim oLocation As Point2d
oLocation = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
'add a new table
Dim oRTB As RevisionTable
oRTB = oRTBs.Add(oLocation)
'add a new row
Call oRTB.RevisionTableRows.Add()
'add a new column of file property: Design Tracking Properties
'>> Part Number
Call oRTB.RevisionTableColumns.Add(kRevisionTableFileProperty,
"{32853F0F-3444-11D1-9E93-0060B03C1CA6}",
5)
'add a custom column. [PropertySetId] is ignored.
' [PropertyIdentifier] should be specified
Call oRTB.RevisionTableColumns.Add(kRevisionTableCustomProperty, "", "MyCustomProperty")
'add a date property
'one table can only have one Date column
Dim oEachCol As RevisionTableColumn
Dim hasDate As Boolean
hasDate = False
For Each oEachCol In oRTB.RevisionTableColumns
If oEachCol.PropertyType = kRevisionTableDateProperty Then
hasDate = True
Exit For
End If
Next
If hasDate = False Then
Call oRTB.RevisionTableColumns.Add(kRevisionTableDateProperty)
End If
End Sub