'ExcelApp.Visible causing Error 91 and I can't figure out how to fix it

A little background: A former employee wrote a VBA program to run in AutoCAD to generate G-code based off of CAD entities. The immediate problem is that it currently only runs in AutoCAD 2002 on a computer running Windows XP on a virtual desktop. Obviously, that doesn't work so I'm trying to get it to work on BricsCad V21. My current issue is that I keep getting a Run time error 91 at the following place and I do not understand what the issue is or how to overcome it.

Please note that I am a VERY beginner programmer and am still trying to wrap my head around how all of this works. Any help you can provide would be most appreciated.

Public ExcelApp As Excel.Application
Public wbkObj As Excel.Workbook
Public shtObj As Excel.Worksheet
Public rngObj As Excel.Range

These are the relevant declarations at the beginning of the program

Sub CAM_A_CHEST()
Set ExcelApp = CreateObject("Excel.Application")
Set wbkObj = ExcelApp.workbooks.Add
Set shtObj = ExcelApp.Worksheets(1)
If Err <> 0 Then
    MsgBox "Could not start Excel", vbExclamation
    End
Else
    ExcelApp.Visible = True
    Application.Visible = True
    ExcelApp.ScreenUpdating = True
    Set rngObj = shtObj.Range(Cells(1, 1), Cells(1, 5))
    With rngObj
        .NumberFormat = "0"
        .Font.Name = "Arial"
        .Font.FontStyle = "Bold"
        .Font.Size = 10
        '.Font.ColorIndex = xlAutomatic
    End With
    With shtObj.Range(Cells(2, 1), Cells(2000, 13))
        .NumberFormat = "0.000"
        .Font.Name = "Arial"
        .Font.FontStyle = "Regular"
        .Font.Size = 9
        .Value = ""
    End With
    With shtObj.Range(Cells(2, 5), Cells(2000, 5))
        .NumberFormat = "0"
    End With
    shtObj.Range("A1:D1").Select
    Selection.NumberFormat = "General"
    shtObj.Cells(1, 1).ColumnWidth = 18
    shtObj.Cells(1, 1) = "Layer"
    shtObj.Cells(1, 2) = "Center X"
    shtObj.Cells(1, 3) = "Center Y"
    shtObj.Cells(1, 4) = "Diameter"
    shtObj.Cells(1, 5) = "Sort"
    shtObj.Cells(1, 7).Font.FontStyle = "Bold"
    shtObj.Cells(1, 7).Font.Size = 10
    Range("A2").Select
    ActiveWindow.FreezePanes = True
End If
    
'ExcelApp.Visible = False
transZ$ = "2.00"

divNum$ = ""
grpNum$ = "0"

Load UserForm1
Load UserForm2
Load UserForm3
Load procUserForm

Call UserForm_Initialize

That is the chunk of code that opens Excel, formats the Worksheet, and prepares for inputs from AutoCAD. Later on in the code, The following Sub is called:

Sub CAM_TopAndBottomBoards()

    Dim I As Integer
    Dim mspaceObj As AcadObject
    Dim centerPoint As Variant
    Dim ExcelApp As Excel.Application
    

increment = 0
Call InitializeCounters
SelectStuff:
'Find entities representing Pitman Holes, Pipe Holes, etc., among items selected,
'     dump data into Excel sheet
ExcelApp.Visible = True

It's that last line that is generating the error.

At this point I've spent a couple of days on this issue and I'm completely stuck. Help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source