bonsoir
Je ne sais pas s'il existe un code VBA pour masquer/réafficher le ruban.
En attendant, ci joint une macro qui simule le raccourci clavier Ctrl+F1 ( à lancer impérativement depuis la feuille de calcul ).
Code:
Option Explicit
Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Sub Masquer_Afficher_Ruban()
'Simule Ctrl+F1 (à lancer depuis la feuille de calcul)
Const VK_CONTROL = &H11
Const VK_F1 = &H70
Const KEYEVENTF_KEYUP = &H2
keybd_event VK_CONTROL, 0, 0, 0
keybd_event VK_F1, 0, 0, 0
keybd_event VK_F1, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
End Sub
et si tu utilises la macro depuis un CommandButton (placé sur la feuille de calcul)
Code:
Option Explicit
Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Sub CommandButton1_Click()
'Simule Ctrl+F1 (à lancer depuis la feuille de calcul)
Const VK_CONTROL = &H11
Const VK_F1 = &H70
Const KEYEVENTF_KEYUP = &H2
Range("A1").Select
DoEvents
keybd_event VK_CONTROL, 0, 0, 0
keybd_event VK_F1, 0, 0, 0
keybd_event VK_F1, 0, KEYEVENTF_KEYUP, 0
keybd_event VK_CONTROL, 0, KEYEVENTF_KEYUP, 0
End Sub
Bonne soirée
MichelXld