none
ActiveX Bug when exiting the Excel application RRS feed

  • Question

  • I have a worksheet form consisting of multiple ActiveX controls. I have a common procedure to which I pass each ActiveX control when its LostFocus event fires. This common procedure updates each control's corresponding cell in a structured data table. This procedure works fine as I work with the various controls on the form.

    BUT, if one utilizes the X on the top right of the Excel application window to Exit Excel, causing the currently active ActiveX control's LostFocus event to fire, calling the common procedure from the LostFocus event code fails with a run time error 13 Type Mismatch. Interestingly, the problem does not occur if I just close the workbook from the Excel application File menu.

    The code in each ActiveX LostFocus event consists of one line formatted as follows, so I have trouble believing this is a coding issue.

    SetLostFocus FrmDataRec.OLEObjects("cbxCategory")
    Does anyone have any idea what might be causing this to happen when exiting Excel? I'm running out of ideas.


    phillfri


    • Edited by phillfri Monday, February 25, 2019 2:22 AM
    Friday, February 22, 2019 5:27 AM

Answers

  • Resolved. The run time error 13 Type Mismatch that Excel throws up under the circumstance described in the original post is bogus. If you set Application.DisplayAlerts to False and then insert On Error Resume Next the code will continue to run and you will find that the ActiveX controls are still available and accessible. It's obviously a bug in Excel.

    phillfri

    • Marked as answer by phillfri Monday, February 25, 2019 2:22 AM
    Monday, February 25, 2019 2:21 AM