Тема: 2007 и 2008 автокад
Почему на 2008 автокаде вот этот код работает, а на 2007 нет:
Option Explicit Sub Table() Dim fType(0 To 1) As Integer, fData(0 To 1) Dim adNumRows As Integer Dim adInsertPnt As Variant Dim adTable As AcadTable Dim adRow As Long Dim pStr As String 'Our table will start with just two rows for the Title and the Header adNumRows = 2 'Let the user pick the insertion point adInsertPnt = ThisDrawing.Utility.GetPoint(, "Select insertion point for table>>") 'Create the table. We will create it with 3 columns each with a width of 61 and adjust ' them in the next step. Figure the total width of your table and divide it by your ' number of columns (3 for us) for this figure. Set adTable = ThisDrawing.ModelSpace.AddTable(adInsertPnt, adNumRows, 3, 18, 66) If Err Then adTable.Delete Set adTable = ThisDrawing.ModelSpace.AddTable(adInsertPnt, adNumRows, 3, 18, 66) End If 'With the table created we can make the columns the widths we need adTable.SetColumnWidth 0, 40 adTable.SetColumnWidth 1, 40 adTable.SetColumnWidth 2, 118 'Populating the table cells is unacceptably slow unless we set the following property ' to True. This is because with each update AutoCAD wants to recreate the entire table ' from scratch. Try commenting out this line for a test but be sure to save your work ' first in case you need to kill the process... adTable.RegenerateTableSuppressed = True 'This property repeats the Title and Header rows if the table is resized using the Break grip adTable.RepeatTopLabels = True 'Add the table text. If Table styles in your drawing are set you could remove the cell ' style settings in the macro 'The title adTable.SetText 0, 0, "Опоры ВЛИ" adTable.SetTextStyle2 0, 0, 0, "STANDARD" adTable.SetTextHeight2 0, 0, 0, 12 adTable.SetCellAlignment 1, 1, acMiddleCenter 'The column headers adTable.SetText 1, 0, "Наименование" adTable.SetTextStyle2 1, 0, 0, "STANDARD" adTable.SetTextHeight2 1, 0, 0, 10 adTable.SetCellAlignment 1, 1, acMiddleCenter adTable.SetText 1, 1, "Марка" adTable.SetTextStyle2 1, 1, 0, "STANDARD" adTable.SetTextHeight2 1, 1, 0, 10 adTable.SetCellAlignment 1, 1, acMiddleCenter adTable.SetText 1, 2, "Колличество" adTable.SetTextStyle2 1, 2, 0, "STANDARD" adTable.SetTextHeight2 1, 2, 0, 10 adTable.SetCellAlignment 1, 2, acMiddleCenter 'Table rows are Zero based so our first data row is '2' adRow = 2 ' and data to create a sorted list. adTable.InsertRows adRow, 18, 1 pStr = n1 adTable.SetText adRow, 0, pStr adTable.SetTextStyle2 adRow, 0, 0, "STANDARD" adTable.SetTextHeight2 adRow, 0, 0, 10 adTable.SetCellAlignment adRow, 0, acMiddleCenter pStr = k1 adTable.SetText adRow, 1, pStr adTable.SetTextStyle2 adRow, 1, 0, "STANDARD" adTable.SetTextHeight2 adRow, 1, 0, 10 adTable.SetCellAlignment adRow, 1, acMiddleCenter 'pStr = n3 ' adTable.SetText adRow, 2, pStr ' adTable.SetTextStyle2 adRow, 2, 0, "STANDARD" ' adTable.SetTextHeight2 adRow, 2, 0, 10 ' adTable.SetCellAlignment adRow, 2, acMiddleCenter adRow = adRow + 1 'Restore the Table Regeneration and the table will be built adTable.RegenerateTableSuppressed = False End Sub