Results 1 to 17 of 17

intercept & cancel keystroke Events when CommandButton is active

Threaded View

  1. #1
    Forum Contributor
    Join Date
    08-09-2005
    MS-Off Ver
    2003 & 2007
    Posts
    111

    intercept & cancel keystroke Events when CommandButton is active

    I'm building an Excel worksheet into a kind of dashboard with CommandButtons and TextBoxes to drive the functionality of the rest of the document.

    I'm trying to recreate some of the functionality of a UserForm (e.g., tab order). I'm using the CommandButton's KeyDown event to respond if the user presses Enter:

    Private Sub Button_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    If KeyCode = vbKeyReturn Then
        Call Button_Click
    ElseIf KeyCode = vbKeyTab Then
        If (Shift And 1) > 0 Then
            Me.PreviousButton.Activate
        Else 'no shift
            Me.NextButton.Activate
        End If
    End If
    End Sub
    The problem is the underlying worksheet also responds to the Enter keystroke (it scrolls down and I'm not sure what else it may be doing), even though it's protected from users selecting cells.

    So how do I control this or intercept keystroke events when a control embedded in a worksheet is active? Is there another strategy I should be following? Any recommended resources?
    Last edited by dlh; 01-14-2010 at 03:28 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1