I do not recall every having so much trouble getting a form to look the way I wanted.
I ended up moving lots of things around that did not, perhaps, need moving. However, I have finally got the effect I believe you seek so I have not tried to move code back to where it was.
The first key change appears to be:
Property StartUpPosition of UserForm1 = 0 - Manual`
without this, I could not set the form's height to the full available height. Setting .Top had no effect.
The second key change appears to be use of:
Application.DisplayFullScreen = True
I do not recall needing this command before but maximizing the window state would not give the full screen height.
I discarded your routines Sub maximizeWindows()
and Sub UserForm_initialize()
either because I did things differently or because I moved the code. I am sure you could move the code back but I have not tried.
I added a new control cmdExit
with the following event routine:
Private Sub cmdExit_Click()
Unload Me
End Sub
Sub runDemo()
has become:
Sub runDemo()
Application.DisplayFullScreen = True
Load UserForm1
With UserForm1
.Top = 2
.Left = 0
.Width = Application.UsableWidth
.Height = Application.UsableHeight - 2
.Frame1.Move 0, 0, .InsideWidth, 300
.Frame2.Left = .Frame1.Left + .Frame1.InsideWidth - .Frame2.InsideWidth
.Show
End With
Application.DisplayFullScreen = False
End Sub
The effect of the above for me was:
- UserForm1 occupied the entire screen apart from the Windows Task bar along the bottom.
- Frame1 was at the top, occupied the full width of the screen and had a height of 300.
- Frame2 was right aligned with Frame1.
- The maximized/normal/minimized state of Excel was not changed.
Hope this works for you.