Move a Frame in a Userform to a different page

rhombus4

Well-known Member
Joined
May 26, 2010
Messages
586
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I know how to move a frame in a page i.e.
Frame1.Top = 100

What I want to do is move it to a different page
Tried Frame1.MultiPage1.Pages(3).Top = 100 but it wouldn't work


Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
AFAIK, at run-time one cannot move controls from one page of a multipage to a different page.

One can create new controls in the second page, but they cannot be moved.
 
Upvote 0
Thanks Mike
Just wanted to make designing userform easier by having extra page to space out my frames and then move into position using vba
 
Upvote 0
@rhombus4

Not tried it before but have you considered experimenting this via the VBComponent Designer Object ?
 
Upvote 0
You can't put the frame on the page, but you can put it in front of the multipage control so it appears to the user as if it were on that page.

Put code like this in the userform's code module

Code:
Dim pFrame1OnPage As Long

Private Sub MultiPage1_Change()
    Frame1.Visible = (pFrame1OnPage = MultiPage1.Value)
End Sub

Property Get Frame1OnPage() As Long
    Frame1OnPage = pFrame1OnPage
End Property

Property Let Frame1OnPage(inVal As Long)
    pFrame1OnPage = inVal
    Frame1.Visible = (pFrame1OnPage = MultiPage1.Value)
End Property

Private Sub UserForm_Initialize()
    Frame1.ZOrder fmZOrderFront
End Sub

Then you can control which page the frame appears to be on with code like
Code:
Frame1OnPage = 1

Note that pages and the Frame1OnPage value start at 0
Note also that the .Left and .Top properties of the frame are relative to the userform not the Multipage control.
To set the frame's position to the equivalent of 10 you would have to use code like

Code:
Frame1.Top = 10 + Multipage1.Top + (Multipage1.Height - Multipage1.Pages(0).InsideHeight)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,243
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top