XL 2019 comment faire ouvert afficher menu vba

  • Initiateur de la discussion Initiateur de la discussion frederio
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

Bonsoir
je suppose que tu veux ton menu en haut a gauche
tout d'abords il faut affecter une macro a ta shape(ton bouton menu)
la sub affectée
VB:
Sub Image4_Cliquer()
UserForm1.Show
End Sub

ensuite il te faut une fonction pour determiner la position left et top en point de la grille
avec un ersatz de ma fonction perso pour positionner un form sur cell
dans le activate de ton userform
Code:
Private Sub UserForm_Activate()
    Dim Ptopx#
    With ActiveWindow.Panes(1)
        Ptopx = (.PointsToScreenPixelsX(72 / (.Parent.Zoom / 100)) - .PointsToScreenPixelsX(0)) / 72
        Me.Move .PointsToScreenPixelsX(0) / Ptopx, .PointsToScreenPixelsY(0) / Ptopx
    End With
End Sub
et voilà le tour est joué ton menu s'affiche en haut à gauche
demo.gif


j'en ai profiter pour faire une sub general pour le color hover
VB:
Private Sub UserForm_Activate()
    Dim Ptopx#
    With ActiveWindow.Panes(1)
        Ptopx = (.PointsToScreenPixelsX(72 / (.Parent.Zoom / 100)) - .PointsToScreenPixelsX(0)) / 72
        Me.Move .PointsToScreenPixelsX(0) / Ptopx, .PointsToScreenPixelsY(0) / Ptopx
    End With
End Sub

Private Sub UserForm_Initialize()
    Dim a&
    For Each Obj In Me.Controls
        a = a + 1
        Obj.BackColor = RGB(255, 255, 255)
        Obj.Caption = Sheets(a).Name
    Next
End Sub

Private Sub commandbuttonl_click()
    Sheets(Me.CommandButton1.Caption).Select
End Sub
Private Sub commandbutton2_click()
    Sheets(Me.CommandButton2.Caption).Select
End Sub
Private Sub commandbutton3_click()
    Sheets(Me.CommandButton3.Caption).Select
End Sub
Private Sub commandbutton4_click()
    Sheets(Me.CommandButton4.Caption).Select
End Sub
Private Sub commandbutton5_click()
    Sheets(Me.CommandButton5.Caption).Select
End Sub

Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    ColorHover CommandButton1
End Sub
Private Sub CommandButton2_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    ColorHover CommandButton2
    End Sub
Private Sub CommandButton3_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    ColorHover CommandButton3
End Sub
Private Sub CommandButton4_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    ColorHover CommandButton4
End Sub
Private Sub CommandButton5_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    ColorHover CommandButton5
End Sub

Sub ColorHover(ctrl As Object)
Dim Obj As Object
For Each Obj In Me.Controls
        If Obj.Name <> ctrl.Name Then
            Obj.BackColor = RGB(255, 255, 255)
        End If
    Next
    ctrl.BackColor = RGB(15, 215, 15)
End Sub
😉
 

Pièces jointes

- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
5
Affichages
86
Réponses
12
Affichages
492
Réponses
25
Affichages
2 K
Réponses
1
Affichages
232
Réponses
4
Affichages
395
Réponses
1
Affichages
373
Réponses
1
Affichages
233
  • Question Question
XL 2019 SIERREUR
Réponses
3
Affichages
634
Réponses
5
Affichages
480
  • Question Question
XL 2019 date
Réponses
4
Affichages
514
Réponses
8
Affichages
631
Réponses
16
Affichages
995
Réponses
4
Affichages
68
Retour