Code userform plein écran plante [RESOLU]

cp4

XLDnaute Barbatruc
Bonjour:),

Il y a un moment que j'ai trouvé ce code sur le forum. Jusqu'à aujourd'hui, il ne m'a pas posé de problème.
J'ai fait un nouveau formulaire dans lequel j'ai mis un webbrowser mais là le code plante.
J'ai effectué un autre test avec une progressbar et là aussi ça plante.
VB:
Option Explicit

Private Sub UserForm_Activate()
   Dim ctl As Control, ratiow As String, ratioh As String
   ratiow = Application.Width / Me.Width: ratioh = Application.Height / Me.Height
   Me.Left = 0: Me.Top = 0
   Me.Width = Application.Width: Me.Height = Application.Height
   For Each ctl In Me.Controls
      ctl.Left = ctl.Left * ratiow
      ctl.Top = ctl.Top * ratioh
      ctl.Width = ctl.Width * ratiow
      ctl.Height = ctl.Height * ratioh
      ctl.Font.Size = ctl.Font.Size * ratioh  '*** Plante ici ***
   Next
End Sub
Comment contourner ce problème?
Merci par avance.
Bonne journée.
 

Pièces jointes

  • Classeur1.xlsm
    18.9 KB · Affichages: 28

pierrejean

XLDnaute Barbatruc
Bonjour cp4

Ces contrôles n'ont pas de Texte donc pas de Font !!!
Solution:
Code:
Private Sub UserForm_Activate()
   Dim ctl As Control, ratiow As String, ratioh As String
   ratiow = Application.Width / Me.Width: ratioh = Application.Height / Me.Height
   Me.Left = 0: Me.Top = 0
   Me.Width = Application.Width: Me.Height = Application.Height
   For Each ctl In Me.Controls
      ctl.Left = ctl.Left * ratiow
      ctl.Top = ctl.Top * ratioh
      ctl.Width = ctl.Width * ratiow
      ctl.Height = ctl.Height * ratioh
      On Error Resume Next
      ctl.Font.Size = ctl.Font.Size * ratioh
      On Error GoTo 0
   Next
End Sub
 

cp4

XLDnaute Barbatruc
Bonjour cp4

Ces contrôles n'ont pas de Texte donc pas de Font !!!
Solution:
Code:
Private Sub UserForm_Activate()
   Dim ctl As Control, ratiow As String, ratioh As String
   ratiow = Application.Width / Me.Width: ratioh = Application.Height / Me.Height
   Me.Left = 0: Me.Top = 0
   Me.Width = Application.Width: Me.Height = Application.Height
   For Each ctl In Me.Controls
      ctl.Left = ctl.Left * ratiow
      ctl.Top = ctl.Top * ratioh
      ctl.Width = ctl.Width * ratiow
      ctl.Height = ctl.Height * ratioh
      On Error Resume Next
      ctl.Font.Size = ctl.Font.Size * ratioh
      On Error GoTo 0
   Next
End Sub
Oups! :oops::oops::oops: Je suis vraiment confus. Je n'y avais pas pensé.
Bonjour @pierrejean :D. Merci beaucoup:):):);)
Très bonne journée;)
 

Discussions similaires

Réponses
2
Affichages
698

Statistiques des forums

Discussions
312 198
Messages
2 086 153
Membres
103 137
dernier inscrit
Billly