Share via

Excel Userform Frames

Anonymous
2021-07-06T18:46:55+00:00

I'm making a tool with an Excel userform that has 4 frames, separate from each other with their own controls.

I would like to navigate back and fourth between frames.

When I initialize the Userform, I have the first frame (Frame_1) appear with it's controls. It's designed for the user to be able to tab through the controls or click if they choose. All the controls work fine. If the user wants to add their name to a list, I have them click on a control to bring up the second frame (Frame_2) and hide Frame_1. This also does what it's supposed to do.

The problem occurs when I want to navigate back to Frame_1 from Frame_2. I'm able to do this with Frame_2.Visible = False and Frame_1.Visible = True commands, but none of the controls behave on Frame_1 after this occurs. It would be ideal if Frame_1 with all it's controls would act the same as they do when the Userform is initialized. It seems like I need to be able to put focus on the first control in Frame_1 in order to do this. But when I write the code for this, I always get an error that states "Run-time error '-2147467259 (80004005)': Unspecified error"

If I remain within Frame_1 and go through all the controls and put focus on the first control after the last control has executed, I have no issues. This error only occurs when going back from Frame_2 to Frame_1

So I would like to know if this makes sense? Is this common? and Is there is a workable solution? I can't seem to find anything online.

Any help would be appreciated.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2021-07-06T20:13:48+00:00

    Sample file:

    https://www.dropbox.com/s/ea2cqrbld4x5qjr/99db2cae-2f0c-4deb-9422-8f4e98c6f74b.xlsm?dl=1

    If have no problems to switch the frames. Show us a sample to reproduce the issue.

    Andreas.

    0 comments No comments
  2. Anonymous
    2021-07-06T19:54:36+00:00

    This would solve my problem functionally, but I should also add that I'm trying to make this tool UX friendly and there doesn't seem to be a way to change colors with multipage tabs like there are with frames. At least not that I can find.

    0 comments No comments
  3. HansV 462.6K Reputation points MVP Volunteer Moderator
    2021-07-06T19:31:41+00:00

    Instead of four frames, I would use a MultiPage control with four tab pages. Activating a tab automatically shows the controls on that tab and hides the controls on the other tabs.

    If you wish, you can set the Style property of the MultiPage control to 2 - fmTabStyleNone. This will hide the clickable tabs; you can still switch between tabs using code.

    See for example Excel VBA: Using the MultiPage Control in your Userforms

    0 comments No comments