Make the UserForm full screen and center the controls.

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

3 réponses

Zoul67 Posted messages 2001 Status Membre 149
 
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.
0
ajca29 Posted messages 9 Status Membre
 
Thank you Zoul67,
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
0
Zoul67 Posted messages 2001 Status Membre 149
 
Is your file confidential or can you make it available to us (on cjoint.com for example)?
0
ajca29 Posted messages 9 Status Membre
 
Of course, it is uploaded on cjoint.com.
Thanks again
ajca29
0
Zoul67 Posted messages 2001 Status Membre 149
 
Thank you for providing the link corresponding to your file. You only mentioned cjoint.com ...
0
ajca29 Posted messages 9 Status Membre
 
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.
0
ajca29 Posted messages 9 Status Membre
 
The link is https://www.cjoint.com/?0IehlgxTX5mp

I admit I don't quite understand how cjoint works
Best regards
ajca29
0
lermite222 Posted messages 9042 Status Contributeur 1 199
 
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.
0
ajca29 Posted messages 9 Status Membre
 
Thank you for the tutorial, it’s indeed Excel 2007.
Best regards
ajca29
0