Make the UserForm full screen and center the controls.
ajca29
Posted messages
9
Status
Membre
-
ajca29 Posted messages 9 Status Membre -
ajca29 Posted messages 9 Status Membre -
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 réponses
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.
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.
The link is https://www.cjoint.com/?0IehlgxTX5mp
I admit I don't quite understand how cjoint works
Best regards
ajca29
I admit I don't quite understand how cjoint works
Best regards
ajca29
But I've tried all the codes and even added the module recommended by Didier09, but nothing works.
I have the user form in full screen and all the controls are correctly placed on the left side of the form. That's what I'm missing.
Best regards
ajca29
Thanks again
ajca29
When I go to cjoint, it tells me that the link is not available or no longer available.
This is a new link.