Excel crashing without error when form.Controls.Add is called


Excel 2016 version 1811 (build 11029.20079 Click-to-Run) is crashing without error when the following code is called from a user's interaction with a UserForm. Thing is, it only crashes in THIS (main) UserForm. If I add the container to any other UserForm it executes without any issue.

Private container As Object

'Purpose: Create the container frame that holds the page title and preview image
Private Sub createContainer()
    Set container = main.pageThumbnails.Controls.add("Forms.Frame.1", name) ' Break here, continuing causes *CRASH*

    With container
        .Caption = ""

        .height = containerHeight
        .width = containerWidth
        .Left = 12
        .top = areaHeight

        .BackColor = defaultBackColor
        .BorderColor = defaultBorderColor
    End With

    With main.pageThumbnails
        .ScrollHeight = areaHeight
    End With

End Sub

Checking Windows Event Viewer gives me the following:

Faulting application name: EXCEL.EXE, version: 16.0.11029.20079, time stamp: 0x5bf4c8c3
Faulting module name: coml2.dll, version: 10.0.17134.407, time stamp: 0xaad4943a
Exception code: 0xc0000005
Fault offset: 0x0000000000016521
Faulting process id: 0x100788
Faulting application start time: 0x01d48cb0460efe6f
Faulting application path: C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE
Faulting module path: C:\WINDOWS\System32\coml2.dll
Report Id: 3ff6565e-7c37-4733-87fd-7e5ab12cba1f
Faulting package full name: 
Faulting package-relative application ID: 

Things I've tried:

  1. Running in compatibility mode (Windows 7 and 8)
  2. Moving the file from a network location to my Downloads folder on the local machine
  3. Casting container as an MSForms.frame instead of an Object
  4. Restarting the computer and Excel
  5. Running Excel in safe mode: excel.exe /s
  6. Changing container from Private to Public and referencing Me.container
  7. Tried each (and every) method provided by Microsoft here
  8. Installed the KB4011128 update from Microsoft. It detected an issue and "fixed it" but the problem remains
  9. Redditors suggested that uninstalling update 4018319 could fix the issue but I don't have it installed.
  10. Referencing the main form using a singleton module instead of main.thumbnails
  11. Creating the frame on the main form code-behind
  12. Referencing the created frame from a singleton module
  13. Created a new .xlsm file, copied over all class, modules, and forms (except main). Created main from scratch
  14. Added a newly created CommandButton to the frame (this worked...)
  15. Changed the Id of thumbs frame to a bunch of random letters
asked on Stack Overflow Dec 5, 2018 by kneeki • edited Feb 15, 2020 by braX

1 Answer


Throughout my searching I found other people with the same crash and error logs in Windows Event Viewer. None of those posts were using VBA as I was. I solved the issue by deleting the referenced Control main.pageThumbnails and recreating it in the editor.

At this time I have no idea what caused the issue nor if this solution is permanent.

Update 30 Jan 2019

After continuing to struggle with this issue and not coming up with a final solution or even an explanation as to why it's happening I created a workaround.

Instead of adding a MSForms.Frame object to the container I instead added the frame contents (an image and four labels) to the container and control their positioning via a Sub setTop method.

At this moment I'm unsure of the performance impact but at least I'm able to continue working on additional functionality.

answered on Stack Overflow Dec 6, 2018 by kneeki • edited Jan 30, 2019 by kneeki

User contributions licensed under CC BY-SA 3.0