'title of table Dim sTitle As String = "CONTENTS" Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument 'create table on sheet 1 Dim oS As Sheet = oDoc.Sheets(1) Dim sDrwNo As String Dim sShNo As String Dim sDrwDesc As String 'search for existing table Dim oTable As CustomTable = Nothing For Each eTable As CustomTable In oS.CustomTables If eTable.Title = sTitle Then oTable = eTable Exit For End If Next 'collect sheets, exclude sheets with ExcludeFromCount Dim oColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection Dim eS As Sheet For Each eS In oDoc.Sheets If Not eS.ExcludeFromCount Then oColl.Add(eS) End If Next 'column titles Dim NoOfCols As Integer = 3 Dim oTitles(NoOfCols - 1) As String oTitles(0) = "Drawing No." oTitles(1) = "Sheet No" oTitles(2) = "Drawing Description" iShCount = oColl.Count iSh = 1 'collect table values Dim oTitle As TitleBlock Dim oContents(oColl.Count * NoOfCols - 1) As String For i = 1 To oColl.Count eS = oColl(i) sDrwNo = "na" sShNo = "na" sDrwDesc = "na" 'search for prompted text in titleblock oTitle = eS.TitleBlock For Each oTB As TextBox In oTitle.Definition.Sketch.TextBoxes If (oTB.Text = "DWG No") Then sDrwNo = oTitle.GetResultText(oTB) End If If (oTB.Text = "Drawing Description") Then sDrwDesc = oTitle.GetResultText(oTB) End If Next oContents(i * NoOfCols - 3) = sDrwNo oContents(i * NoOfCols - 2) = sShNo oContents(i * NoOfCols - 1) = sDrwDesc iSh = iSh + 1 Next 'column widths Dim oColumnWidths(NoOfCols - 1) As Double oColumnWidths(0) = 5 oColumnWidths(1) = 3 oColumnWidths(2) = 10 'insertion point Dim InsPt As Point2d If oTable IsNot Nothing Then 'insertion point of existing table InsPt = oTable.Position oTable.Delete Else 'upper left position for new table InsPt = ThisApplication.TransientGeometry.CreatePoint2d(1, oS.Height - 1) End If 'create table Dim oCustomTable As CustomTable oCustomTable = oS.CustomTables.Add(sTitle, InsPt, NoOfCols, oColl.Count, oTitles, oContents, oColumnWidths)