Send Keys to Open Userform

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
 
R

r

'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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top