Send Keys to Open Userform

  • Thread starter Thread starter mrkt_rwnd
  • Start date Start date
M

mrkt_rwnd

Is it possible to SendKeys to an Open/ Running Userform from another
macro once that Userform is waiting for a user action, say using
accelerator keys. It seems I can only do this from the keyboard once
the Userform is open. Thanks Gang! My turn to try answering some
questions too. Best, J
 
'xxxxxxxxxxxxxxxxxxxxxx
'in the standard module
Sub test()
UserForm1.Show 0
End Sub

Sub YourMacro()
UserForm2.Show 0
End Sub

'xxxxxxxxxxxxxxxxxxxxxxx
'in the userform1 module

Private Sub UserForm_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
'Ctrl+k
Debug.Print KeyCode
If KeyCode = 17 And Shift = 2 Then
YourMacro
End If
End Sub

regards
r
 
Back
Top