Public Declare Sub keybd_event Lib "user32.dll" ( _
ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const VK_RETURN = &HD
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Const VK_Z = &H5A 'pour l'exemple
Sub LanceUserForm()
Dim i&
'### Saute la tabulation/focus sur TextBox4 ###
'### mais on peut y accéder à la main
UserForm1.TextBox4.TabStop = False
'### Bloque l'accès à TextBox4 ###
''With UserForm1.TextBox4
'' .Text = Format(Now, "dd/mm/yy")
'' .Locked = True ' OU ALORS .Enabled = False
''End With
'--- Donne le focus à la 3ème TextBox ---
UserForm1.Controls("TextBox3").SetFocus
'--- Y inscrit 5 fois "z" ---
For i& = 1 To 5
keybd_event VK_Z, 0, 0, 0
keybd_event VK_Z, 0, KEYEVENTF_KEYUP, 0
Next i&
'### Ce qui vous intéresse ###
'--- Simule Enter (donne le focus au contrôle suivant) ---
keybd_event VK_RETURN, 0, 0, 0
keybd_event VK_RETURN, 0, KEYEVENTF_KEYUP, 0
'#############################
'--- Active le UserForm ---
UserForm1.Show
End Sub