Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi Forum,
I am trying to create a custom table using iLogic and not VBA. I found a working code but it's only for VBA and I am trying to rewrite it using iLogic. The VBA code is as follows:
Public Sub CreateCustomTable()
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
' Set a reference to the active sheet.
Dim oSheet As Sheet
Set oSheet = oDrawDoc.ActiveSheet
' Set the column titles
Dim oTitles(1 To 3) As String
oTitles(1) = "Part Number"
oTitles(2) = "Quantity"
oTitles(3) = "Material"
' Set the contents of the custom table (contents are set row-wise)
Dim oContents(1 To 9) As String
oContents(1) = "1"
oContents(2) = "1"
oContents(3) = "Brass"
oContents(4) = "2"
oContents(5) = "2"
oContents(6) = "Aluminium"
oContents(7) = "3"
oContents(8) = "1"
oContents(9) = "Steel"
' Set the column widths (defaults to the column title width if not specified)
Dim oColumnWidths(1 To 3) As Double
oColumnWidths(1) = 2.5
oColumnWidths(2) = 2.5
oColumnWidths(3) = 4
' Create the custom table
Dim oCustomTable As CustomTable
Set oCustomTable = oSheet.CustomTables.Add("My Table", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), _
3, 3, oTitles, oContents, oColumnWidths)
' Change the 3rd column to be left justified.
oCustomTable.Columns.Item(3).ValueHorizontalJustification = kAlignTextLeft
' Create a table format object
Dim oFormat As TableFormat
Set oFormat = oSheet.CustomTables.CreateTableFormat
' Set inside line color to red.
oFormat.InsideLineColor = ThisApplication.TransientObjects.CreateColor(255, 0, 0)
' Set outside line weight.
oFormat.OutsideLineWeight = 0.1
' Modify the table formats
oCustomTable.OverrideFormat = oFormat
End Sub
Here's what I've written but it doesn't seem to work:
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument Dim oSheet As Sheet = oDrawDoc.ActivateSheet Dim oTitles As New ArrayList 'oTitles.Add("Part Number") 'oTitles.Add("Qty") 'oTitles.Add("Material") oTitles(1) = "Part Number" oTitles(2) = "qty" oTitles(3) = "Material" Dim oContents As New ArrayList oContents.Add("1") oContents.Add("1") oContents.Add("Brass") oContents.Add("2") oContents.Add("2") oContents.Add("Aluminum") oContents.Add("3") oContents.Add("1") oContents.Add("Steel") Dim oColumnWidths As New ArrayList oColumnWidths.Add(2.5) oColumnWidths.Add(2.5) oColumnWidths.Add(4) Dim oCustomTables As CustomTable = oSheet.CustomTables.Add("My Table", ThisApplication.TransientGeometry.CreatePoint2d(15, 15), _ 3, 3, oTitles, oContents, oColumnWidths)
Best regards,
Felix Cortes
Solved! Go to Solution.