XL 2016 Bloquer la position d'un USF

dodineau

XLDnaute Occasionnel
Bonjour,
Connaissez vous une commande VBA pour bloquer le déplacement d'un userform ?
Merci.
 

Temjeh

XLDnaute Accro
Supporter XLD
Bonjour dodineau, mapomme

Une variante qui aussi le centre (sans déclaration de variables!)

VB:
Private Sub UserForm_Initialize()

    LargeurFenêtre = Application.Width
    HauteurFenêtre = Application.Height
    PositionGauche = Application.Left
    PoisitionHaut = Application.Top

    Me.Left = (PositionGauche + LargeurFenêtre) - ((LargeurFenêtre + Me.Width) / 2)
    Me.Top = (PoisitionHaut + (HauteurFenêtre / 2)) - Me.Height / 2

End Sub

Private Sub UserForm_Layout()

    LargeurFenêtre = Application.Width
    HauteurFenêtre = Application.Height
    PositionGauche = Application.Left
    PoisitionHaut = Application.Top

    Me.Left = (PositionGauche + LargeurFenêtre) - ((LargeurFenêtre + Me.Width) / 2)
    Me.Top = (PoisitionHaut + (HauteurFenêtre / 2)) - Me.Height / 2

End Sub
 

mapomme

XLDnaute Barbatruc
Supporter XLD
Bonsoir @dodineau, @Temjeh, @arthour973,

Une nouvelle version testée cette fois ci :
VB:
Option Explicit
Dim TopInit, LeftInit

Private Sub UserForm_Initialize()
  TopInit = "x"
End Sub

Private Sub UserForm_Layout()
  If TopInit = "x" Then TopInit = Me.Top: LeftInit = Me.Left
  Me.Move LeftInit, TopInit
End Sub
 

Pièces jointes

  • dodineau- USF Pas bouger- v1a.xlsm
    18.2 KB · Affichages: 17
Dernière édition:

Discussions similaires

Réponses
13
Affichages
657

Statistiques des forums

Discussions
312 111
Messages
2 085 403
Membres
102 883
dernier inscrit
jameseyz