Make the UserForm full screen and center the controls.
ajca29
Posted messages
9
Status
Member
-
ajca29 Posted messages 9 Status Member -
ajca29 Posted messages 9 Status Member -
Hello,
I have a sports results management program and my issue is as follows:
- I can display the userform in full screen but the controls are correctly represented, only on the left side of the userform (with only the initialize part).
- The attached code, activate, only shows a small portion of the userform at the top left of the screen.
Could you suggest a solution for me?
Thank you for your help
Best regards
ajca29
Private Sub Workbook_Open()
'Hide the columns containing warnings
Columns("CB:DA").Select
Selection.EntireColumn.Hidden = True
UserForm2.Show
End Sub
Private Sub UserForm_Initialize()
With UserForm2
.StartUpPosition = 3
.Width = Application.Width
.Height = Application.Height
End With
End Sub
Private Sub UserForm_Activate()
Dim RW As Single, RH As Single
Me.Width = ScreenWidth * PointsPerPixel
Me.Height = ScreenHeight * PointsPerPixel
RW = ScreenWidth * PointsPerPixel / Me.Width
RH = ScreenHeight * PointsPerPixel / Me.Height
Dim Ctl As MSForms.Control
For Each Ctl In Me.Controls
Ctl.Move Ctl.Left * RW, Ctl.Top * RH, Ctl.Width * RW, Ctl.Height * RH
Next
End Sub
Private Sub Bouton_Annulation_Click()
TextBox1.Text = "" 'Clear the contents of the TextBox
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Configuration: Windows 8 / Internet Explorer 10.0
I have a sports results management program and my issue is as follows:
- I can display the userform in full screen but the controls are correctly represented, only on the left side of the userform (with only the initialize part).
- The attached code, activate, only shows a small portion of the userform at the top left of the screen.
Could you suggest a solution for me?
Thank you for your help
Best regards
ajca29
Private Sub Workbook_Open()
'Hide the columns containing warnings
Columns("CB:DA").Select
Selection.EntireColumn.Hidden = True
UserForm2.Show
End Sub
Private Sub UserForm_Initialize()
With UserForm2
.StartUpPosition = 3
.Width = Application.Width
.Height = Application.Height
End With
End Sub
Private Sub UserForm_Activate()
Dim RW As Single, RH As Single
Me.Width = ScreenWidth * PointsPerPixel
Me.Height = ScreenHeight * PointsPerPixel
RW = ScreenWidth * PointsPerPixel / Me.Width
RH = ScreenHeight * PointsPerPixel / Me.Height
Dim Ctl As MSForms.Control
For Each Ctl In Me.Controls
Ctl.Move Ctl.Left * RW, Ctl.Top * RH, Ctl.Width * RW, Ctl.Height * RH
Next
End Sub
Private Sub Bouton_Annulation_Click()
TextBox1.Text = "" 'Clear the contents of the TextBox
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Configuration: Windows 8 / Internet Explorer 10.0
3 answers
-
Hello,
Your question is very similar to the topic discussed here: https://forums.commentcamarche.net/forum/affich-4340944-vba-taille-userform-sous-excel#3
The variables in bold in your code are only calculated if you define the associated functions (ScreenWidth,...).
See you.-
-
-
-
-
https://www.cjoint.com/?0Iehv6wdEhj
When I go to cjoint, it tells me that the link is not available or no longer available.
This is a new link.
-
-
The link is https://www.cjoint.com/?0IehlgxTX5mp
I admit I don't quite understand how cjoint works
Best regards
ajca29 -
Hello,
What version of Excel please?
If it's 2007 or later, check out this tutorial.
See you!
--
If you bump into a pot and it sounds hollow, it's not necessarily the pot that's empty. ;-)(Confucius)
Note: I do not respond to private messages for technical questions. And my crystal ball is broken.