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.
Is pageThumbnails
also a frame? And do you have other containers in your userform? If so, this is an Excel bug.
This is an old question but I've just spent hours trying to find a solution so here are my findings.
First, to replicate the issue:
- Create a new UserForm (UserForm1)
- Add a Frame (FrameA)
- Add this code:
Private Sub UserForm_Activate()
Set b = FrameA.Controls.Add("Forms.Frame.1", "FrameB")
End Sub
- Add a module (Module1) with:
Sub showUserForm1()
UserForm1.Show
End Sub
- Run showUserForm1
Everything works fine. Now add a second Frame (FrameC) along with this code in UserForm_Activate(): Set d = FrameC.Controls.Add("Forms.Frame.1", "FrameD")
.
Run showUserForm1 again: Excel crashes. More precisely, it crashes on the first line (if you skip it, the second line works
fine).
After further testings, it appears that it fails only if the frame you are trying to add another frame in is at the back. If you bring successively FrameA or Frame C at the front you will notice that it fails always on the Frame wich is at the back.
So I can think of only 3 possibilities:
- don't use frames and place your controls directly in the UserForm as the OP suggested,
- make sure your frame is at the top in design mode (using Zorder does not work),
- if you can't have your frame at the top (e.g. multiple frames), try by creating them all at runtime (FrameA and FrameB within, then FrameC and FrameD within etc).
I had the same issue, in case anyone comes across this in future, my fix was to recreate the Control in the user form and delete the old one, it then worked.
I had the same issue. A frame, veiw from now on, on the userform that I, with code, want to add multiple frames to due to the requierments of multiple Radiobutton (optionbutton).
My solution was that I need to have a frame already placed in the view, before runing the code, for it to work. Every try were the frame was not in the view would cause Excel to crash and when it is in the view it works.
From looking at the Overwatch Window there might be an issue with the frame.controls collection as it says the Object type can not be interputated.
Edit: Althou not thoroughly tested it seems that the "preplace frame" needs to have the same collection of controls as the frame one wishs to add