Consulting

Results 1 to 5 of 5

Thread: Solved: Disable Space Bar & Delete button

  1. #1

    Red face Solved: Disable Space Bar & Delete button

    How can I disable the space bar button and delete button ?

    is there an easy way to identify keyboard keys in vba ? to they have numbers assigned to them or soemthing ?

  2. #2

    Menu Item

    Where can I get a Menu Item list ?

  3. #3
    You can intercept keys in Excel VBA by using the OnKey method in the Excel application object. Basically you tell Excel to execute a VBA sub when the user hits a button instead of whatever Excel usually does. To set it up you would have to put in the OnKey calls on the workbook_open event in the ThisWorkbook module. It would be something like this:

    [VBA]
    Private Sub Workbook_Open()
    Application.OnKey "{DELETE}", "InterceptKey"
    Application.OnKey " ", "InterceptKey"
    Application.OnKey "{BACKSPACE}", "InterceptKey"

    End Sub[/VBA]

    where you have a public InterceptKey sub in a standard module. This will get called when you hit delete, backspace, or the spacebar. In the workbook_close event you'd have to undo this, passing a blank string rather than "InterceptKey"

    Hope that helps...

    Jon

  4. #4
    Do you know the menuitem number for clearcontents ?

    Call EnableMenuItem(755, Allow) ' pastespecial

  5. #5
    Cheers mate thanks

Posting Permissions

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