<?xml encoding=”UTF-8″>By Adam Nagy
You may want to save the current values of the revision table before doing some modifications to the revision numbers – e.g. as a result of a Vault merger.
Here is a VBA sample showing how to do that:
Sub RevisionTableToCustomTable()
Dim tg As TransientGeometry
Set tg = ThisApplication.TransientGeometry
Dim dd As DrawingDocument
Set dd = ThisApplication.ActiveDocument
Dim s As Sheet
Set s = dd.ActiveSheet
' Get revision table
Dim rt As RevisionTable
Set rt = s.RevisionTables(1)
' Get dimensions
Dim c As Integer
Dim r As Integer
c = rt.RevisionTableColumns.count
r = rt.RevisionTableRows.count
' Counter
Dim i As Integer, j As Integer
' Get headers and column widths
ReDim headers(1 To c) As String
ReDim widths(1 To c) As Double
Dim rtc As RevisionTableColumn
i = 1
For Each rtc In rt.RevisionTableColumns
headers(i) = rtc.Title
widths(i) = rtc.Width
i = i + 1
Next
' Get contents and row heights
ReDim contents(1 To c * r) As String
ReDim heights(1 To r) As Double
Dim rtr As RevisionTableRow
i = 1: j = 1
For Each rtr In rt.RevisionTableRows
Dim rtcell As RevisionTableCell
For Each rtcell In rtr
contents(i) = rtcell.Text
i = i + 1
Next
heights(j) = rtr.Height
j = j + 1
Next
' Create custom table with the content
Dim ct As CustomTable
Set ct = s.CustomTables.Add( _
rt.Title + " (old)", _
tg.CreatePoint2d(), _
c, _
r, _
headers, _
contents, _
widths, _
heights)
' Position it e.g. on top of the revision table
Dim pt As Point2d
Set pt = rt.Position
Call pt.TranslateBy(tg.CreateVector2d( _
0, Abs(ct.RangeBox.MaxPoint.Y - ct.RangeBox.MinPoint.Y)))
ct.Position = pt
End Sub
You could also do it with fewer calls by using Export() on the RevisionTable to save contents to a CSV file and then create a CustomTable using AddCSVTable(), but in that case the table will be bound to the CSV file and that needs to exist along with the drawing file.


Leave a Reply