Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Key events on user form
I'm trying to capture the keycodes so that the focus will move to a specific
control based on whether the user hits TAB or ENTER, or SHIFT+TAB after entering data in a given text box on my form. I've been trying to do so from the Key_Down event of the text box, but am not having much luck. Any help will be greatly appreciated. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Key events on user form
Modify this to do tab or enter or shift or whatever you want. Originally
posted by Ron DeBruin, tests for Control key being pressed. If you need help modifying post. Declare Function GetKeyState Lib "user32" _ (ByVal nVirtKey As Long) As Integer Const VK_CONTROL As Integer = &H11 'Ctrl Sub test() If GetKeyState(VK_CONTROL) < 0 Then Ctrl = True Else Ctrl = False If Ctrl = True Then MsgBox "pressed" Else MsgBox "Not" End If End Sub 'And this in the sheet module Private Sub Worksheet_SelectionChange(ByVal Target As Range) Call test End Sub -- -John Please rate when your question is answered to help us and others know what is helpful. "Ken Warthen" wrote: I'm trying to capture the keycodes so that the focus will move to a specific control based on whether the user hits TAB or ENTER, or SHIFT+TAB after entering data in a given text box on my form. I've been trying to do so from the Key_Down event of the text box, but am not having much luck. Any help will be greatly appreciated. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Key events on user form
John,
The controls and keystrokes I'm trying to manipulate are on a user form, not a spreadsheet. Does this matter? I thought their were internal VBA commands that could be used to achieve my goal here without having to call an external user library. Ken "John Bundy" wrote: Modify this to do tab or enter or shift or whatever you want. Originally posted by Ron DeBruin, tests for Control key being pressed. If you need help modifying post. Declare Function GetKeyState Lib "user32" _ (ByVal nVirtKey As Long) As Integer Const VK_CONTROL As Integer = &H11 'Ctrl Sub test() If GetKeyState(VK_CONTROL) < 0 Then Ctrl = True Else Ctrl = False If Ctrl = True Then MsgBox "pressed" Else MsgBox "Not" End If End Sub 'And this in the sheet module Private Sub Worksheet_SelectionChange(ByVal Target As Range) Call test End Sub -- -John Please rate when your question is answered to help us and others know what is helpful. "Ken Warthen" wrote: I'm trying to capture the keycodes so that the focus will move to a specific control based on whether the user hits TAB or ENTER, or SHIFT+TAB after entering data in a given text box on my form. I've been trying to do so from the Key_Down event of the text box, but am not having much luck. Any help will be greatly appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Getting .NET form to respond to Excel window events | Excel Programming | |||
No events in form displayed from callback routine | Excel Programming | |||
Disable Form Events From Being Triggered | Excel Programming | |||
TurnOff Form Events ? | Excel Programming | |||
Prevent user disabling events | Excel Programming |