PDA

View Full Version : [SOLVED:] Exel crash when VBA frames manipulation



Le Pat
05-31-2021, 05:10 AM
Hi everybody !
I have a failure when I manipulate frames through VBA code and I don't know why...
The context : I have two frames in a user form
In each frame, I try to insert another frame.
If the user form contains one frame, it's ok. As soon as there is two frames, Excel fails and crashes.
I attached a piece of code which illustrate the problem.
If you have any idea, I will appreciate...
Thanks in advance for your answers.

snb
05-31-2021, 08:12 AM
Do not mani[pulate a userform in real-time.
Design the userform completely in design mode and make elements visible/invisible in realtime.

Le Pat
05-31-2021, 08:36 AM
Do not mani[pulate a userform in real-time.
Design the userform completely in design mode and make elements visible/invisible in realtime.
I cannot do that because I don't know in advance the number of "sub-frames"...

SamT
05-31-2021, 11:19 AM
I cannot do that because I don't know in advance the number of "sub-frames"...
Sure you can... Make one sub frame, add all the controls you will ever need on any sub frame. Make all the controls invisible, Copy that sub frame and make the copy invisible, repeat 50 times. Make the original invisible. Write code for all.

As you need a new sub frame visible, make one visible and make the controls it needs visible. Track locations and sizes.

Have fun

Le Pat
05-31-2021, 11:27 AM
Sure you can... Make one sub frame, add all the controls you will ever need on any sub frame. Make all the controls invisible, Copy that sub frame and make the copy invisible, repeat 50 times. Make the original invisible. Write code for all.

As you need a new sub frame visible, make one visible and make the controls it needs visible. Track locations and sizes.

Have fun
Thanks for your reply but honestly, I don't ike this way of doing.

Anyway, I found the solution : the two initial frames have to be created 'by code' instead of "by design' and everything works

SamT
05-31-2021, 01:01 PM
Thanks for your reply but honestly, I don't ike this way of doing.
I don't either. I'm glad you found an alternative