0

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.

orange-donut
  • 201
  • 1
  • 4
  • 1
    https://stackoverflow.com/a/62834391/11683? – GSerg Jan 18 '21 at 16:41
  • This is line 20 70 oSheet.Cells(2, 1).Value = "World" – user14797724 Jan 19 '21 at 01:35
  • @user14797724 - The Erl function (get error line number) used by my DisplayError call uses a user-defined label at the beginning of each line to determine the line number. I defined line 20 to the call to create the Application object. – orange-donut Jan 20 '21 at 15:53

1 Answers1

0

I had my customer's IT person do repair install of Office. After that was done, my customer was able to use my program's Office integration without the error.

orange-donut
  • 201
  • 1
  • 4