In the process of working through this AU handout, on Integration of AutoCAD VBA with MS Excel by Dave Espinosa, I've come across an error message in this code when I've tried to run it.

Error Massage: Object doesn't support this property or method. at'

If ent.EntityType = acBlockReference And ent.Name = bnam Then btot = btot + 1

1 - Any ideas on why it is doing this?
2 - What is needed to fix it?

Thanks

Wayne
Note: form requires three comand buttons and the list boxes.


Code:
Public excelApp As Object
Public wkbObj As Object
Public shtObj As Object
Sub CommandButton1_Click()
Dim i, j, btot As Integer
Dim bnam As String
Dim ent As Object
btot = ThisDrawing.Blocks.Count
For i = 0 To btot - 1
bnam = ThisDrawing.Blocks.Item(i).Name
If Not Mid$(bnam, 1, 1) = "*" Then ListBox1.AddItem bnam
Next i
For i = 0 To ListBox1.ListCount - 1
bnam = ListBox1.List(i): btot = 0
For j = 0 To ThisDrawing.ModelSpace.Count - 1
Set ent = ThisDrawing.ModelSpace.Item(j)
If ent.EntityType = acBlockReference And ent.Name = bnam Then btot = btot + 1
Next j
ListBox2.AddItem btot
Next i
End Sub
Sub CommandButton2_Click()
On Error Resume Next
Set excelApp = GetObject(, "Excel.Application")
If Err <> 0 Then
Err.Clear
Set excelApp = CreateObject("Excel.Application")
If Err <> 0 Then
MsgBox "Could not start Excel!", vbExclamation
End
End If
End If
excelApp.Visible = True
Set wbkObj = excelApp.Workbooks.Add
Set shtObj = wbkObj.Worksheets(1)
shtObj.Name = "Block Count"
Dim i, j, btot As Integer
Dim bnam As String
j = 1
For i = 0 To ListBox1.ListCount - 1
bnam = ListBox1.List(i)
btot = ListBox2.List(i)
shtObj.Cells(j, 1).Value = bnam
shtObj.Cells(j, 2).Value = btot
j = j + 1
Next i
End Sub
Sub CommandButton3_Click()
End ‘or ExcelApp.Quit Unload Me
End Su