The slowness is expected when you have to garb a few hundreds of value by
looping through cells in Excel sheet, using auotmation, For each value, the
communication has to pass through 2 applications' (ACAD and Excel) process
boundary. Not to mention the added layer of .NET Interop. Also, populating
AcadTable object itself in Acad is quite heavy process.
In your case, at least you can improve reading data from Excel part
significantly by using ADO/DAO/ADO.NET to read needed data into Acad in one
shot. Basically you can use MS Jet Oledb provider to open a ADO/DAO
RecordSet/ADO.NET DataSet/DataTable/Array, and then populate the Acad table.
"Nate Hunter" wrote in message
news:5101549@discussion.autodesk.com...
I am having problems inputting excel info into an AutoCAD table. The code
below works great with small amounts of info but when I have more the 520
(just an example # I have been using) excel cells to go through When
inputting into the AutoCAD Table takes a very long time. Any ideas how to
speed this up? Below is my code:
Dim MyExcel As Excel.Application
Dim InsPt(0 To 2) As Double
Dim MyExcelApp As New Excel.Application
Dim MyExcelWB As Excel.Workbook
Dim MyExcelS As Excel.Worksheet
Dim intRows As Integer
Dim intCols As Integer
Dim i As Long
Set MyExcelWB = MyExcelApp.Workbooks.Open(MyPath & "\" & MyFile)
Set MyExcelS = MyExcelWB.Sheets(1)
intRows = MyExcelS.UsedRange.Rows.Count - 4
intCols = MyExcelS.UsedRange.Columns.Count
Set myTable = ThisDrawing.ModelSpace.AddTable(InsPt, intRows, intCols,
1, 1)
myTable.HeaderSuppressed = True
myTable.TitleSuppressed = True
For Y = 1 To intRows
pb1.Value = pb1.Value + 1
'go through each column in the table
For X = 1 To intCols
myTable.SetCellAlignment Y - 1, X - 1, acMiddleCenter
myTable.SetCellTextHeight Y - 1, X - 1, "7.5"
'Find the text in the cell of Excel
'*****************
'This next line is the line that takes forever to complete.
myTable.SetText Y - 1, X - 1, UCase(MyExcelS.Cells(Y + 4,
X).Text)
Next X
Next Y