I have a VB6 application that accesses Excel for importing and exporting data. The application references the Microsoft Excel 14.0 Object Library.
One customer has recently started getting automation errors when trying to launch Excel similar to below:
Private Sub cmdOpenExcel_Click()
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSheet As Excel.Worksheet
Dim booApplicationOpen As Boolean
On Error GoTo HandleTheError
10 Screen.MousePointer = vbHourglass
20 Set oXL = CreateObject("Excel.Application")
30 booApplicationOpen = True
40 Set oWB = oXL.Workbooks.Add
50 Set oSheet = oWB.ActiveSheet
60 oSheet.Cells(1, 1).Value = "Hello"
70 oSheet.Cells(2, 1).Value = "World"
80 oXL.Visible = True
ExitRoutine:
90 Screen.MousePointer = vbNormal
Exit Sub
HandleTheError:
DisplayError "cmdOpenExcel_Click", Err, Erl
Resume ExitRoutine
End Sub
I ran the program with the above code on this customer's machine and got the same error as my actual application:
Error # -2147319765, Automation error, Element not found.
cmdOpenExcel_Click, Line 20
Line 20 is the CreateObject statement.
Any idea what this error means?
My customer is using Excel for Microsoft 365 MSO (16.0.13530.20054) 32-bit.