Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am using the following code to make the userform fill the entire screen:
Private mlAppWindowState As Long Private Sub UserForm_Initialize() With Application mlAppWindowState = .WindowState .WindowState = xlMaximized Me.Move .Left, .Top, .Width, .Height End With End Sub Private Sub UserForm_Terminate() Application.WindowState = mlAppWindowState End Sub What I need is VBA to center the userform controls. Maybe I could put the controls inside a frame and I just need to the frame to center. I am not sure. But I need VBA to position the controls. Can someone get me started? -- Thanks Shawn |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just do something like
With Me .cmdOK.Left = .Width \ 2 - .cmdOK.Width \ 2 .cmdQuit.Left = .Width \ 2 - .cmdQuit.Width \ 2 End With in the form activate event -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Shawn" wrote in message ... I am using the following code to make the userform fill the entire screen: Private mlAppWindowState As Long Private Sub UserForm_Initialize() With Application mlAppWindowState = .WindowState .WindowState = xlMaximized Me.Move .Left, .Top, .Width, .Height End With End Sub Private Sub UserForm_Terminate() Application.WindowState = mlAppWindowState End Sub What I need is VBA to center the userform controls. Maybe I could put the controls inside a frame and I just need to the frame to center. I am not sure. But I need VBA to position the controls. Can someone get me started? -- Thanks Shawn |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
the controls have top, left, width and height properties as well, Just
calculate where you want them and then set those attributes. To get the middle of the form, divide the width in half and add it the left position. Subtract half the width of the control to get the left position for the control. Use logic related to that to calculate where you want you controls. -- Regards, Tom Ogilvy "Shawn" wrote: I am using the following code to make the userform fill the entire screen: Private mlAppWindowState As Long Private Sub UserForm_Initialize() With Application mlAppWindowState = .WindowState .WindowState = xlMaximized Me.Move .Left, .Top, .Width, .Height End With End Sub Private Sub UserForm_Terminate() Application.WindowState = mlAppWindowState End Sub What I need is VBA to center the userform controls. Maybe I could put the controls inside a frame and I just need to the frame to center. I am not sure. But I need VBA to position the controls. Can someone get me started? -- Thanks Shawn |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Shawn,
There are various resizer classes out there, most designed for VB5/6 forms rather than VBA userforms, but you could edit to suit. e.g. http://www.dutchthewiz.com/vb/api/ NickHK "Shawn" ... I am using the following code to make the userform fill the entire screen: Private mlAppWindowState As Long Private Sub UserForm_Initialize() With Application mlAppWindowState = .WindowState .WindowState = xlMaximized Me.Move .Left, .Top, .Width, .Height End With End Sub Private Sub UserForm_Terminate() Application.WindowState = mlAppWindowState End Sub What I need is VBA to center the userform controls. Maybe I could put the controls inside a frame and I just need to the frame to center. I am not sure. But I need VBA to position the controls. Can someone get me started? -- Thanks Shawn |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I used this code, for example, and it worked great.
usfWorkOrder.Label1.Left = (usfWorkOrder.Width) / 2 -- Thanks Shawn "Tom Ogilvy" wrote: the controls have top, left, width and height properties as well, Just calculate where you want them and then set those attributes. To get the middle of the form, divide the width in half and add it the left position. Subtract half the width of the control to get the left position for the control. Use logic related to that to calculate where you want you controls. -- Regards, Tom Ogilvy "Shawn" wrote: I am using the following code to make the userform fill the entire screen: Private mlAppWindowState As Long Private Sub UserForm_Initialize() With Application mlAppWindowState = .WindowState .WindowState = xlMaximized Me.Move .Left, .Top, .Width, .Height End With End Sub Private Sub UserForm_Terminate() Application.WindowState = mlAppWindowState End Sub What I need is VBA to center the userform controls. Maybe I could put the controls inside a frame and I just need to the frame to center. I am not sure. But I need VBA to position the controls. Can someone get me started? -- Thanks Shawn |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
userform to appear in the center of the screen | Excel Programming | |||
userform to appear in the center of the screen | Excel Programming | |||
mutlipage in the center of userform | Excel Programming | |||
UserForm position other than center of the screen. | Excel Programming | |||
textbox in userform(vertical center) | Excel Programming |