Mit diesem Code kann man alle Tabellen in einer Zeichnungsdatei des aktuellen Blattes, an den in der Variable ColumsToSplit eingetragenen Spalten trennen und vertikal anordnen.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swDrawing As DrawingDoc
Dim swTableAnnotation As TableAnnotation
Dim swNextTableAnnotation As TableAnnotation
Dim swAnnotation As Annotation
Dim swView As View
Dim ColumnsToSplit As Variant
Dim PositionValues As Variant
Dim i As Integer, j As Integer
Dim TotalHeight As Double
Dim RowCount As Integer
Dim StartPositionX As Double, StartPositionY As Double
Dim Direction As Integer
Sub main()
ColumnsToSplit = Array(1, 5) 'Nach welchen Spalten soll geteilt werden.
Direction = -1 'Das Vorzeichen steuert die Richtung der Verteilung der Tabellen: - nach unten, + nach oben
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDrawing = swModel
Set swView = swDrawing.GetFirstView
Do While Not swView Is Nothing
i = 0
TotalHeight = 0
Set swTableAnnotation = swView.GetFirstTableAnnotation
If Not swTableAnnotation Is Nothing Then
RowCount = swTableAnnotation.RowCount
For j = 1 To RowCount
TotalHeight = TotalHeight + swTableAnnotation.GetRowHeight(j)
Next j
Set swAnnotation = swTableAnnotation.GetAnnotation
PositionValues = swAnnotation.GetPosition
StartPositionX = PositionValues(0)
Do
Set swNextTableAnnotation = swTableAnnotation.Split(swTableSplitLocations_e.swTableSplit_BeforeColumn, ColumnsToSplit(i))
Set swAnnotation = swNextTableAnnotation.GetAnnotation
PositionValues = swAnnotation.GetPosition
StartPositionY = PositionValues(1)
swAnnotation.SetPosition2 StartPositionX, PositionValues(1) + TotalHeight * Direction, PositionValues(2)
i = i + 1
Set swTableAnnotation = swNextTableAnnotation
Loop While i <= UBound(ColumnsToSplit)
End If
Set swView = swView.GetNextView
Loop
End Sub