Consulting

Results 1 to 4 of 4

Thread: Solved: Mouse Right Click, Insert Row Disabled

  1. #1
    VBAX Regular
    Joined
    Aug 2006
    Posts
    9
    Location

    Solved: Mouse Right Click, Insert Row Disabled

    Hello,
    Can you tell me, please, how to disable "Insert Row" when right click with the mouse (not the Insert Row control from the "Worksheet Menu Bar")? And if this is done, how can it be restored to Enabled?

    Thank you,
    Ciorbea

  2. #2
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Place the next code in the code for your sheet. It will disable the right mouse click (will send an esc key after the right click)
    [vba]Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    MsgBox ("u can not use this")
    SendKeys "{ESC}"
    End Sub[/vba]
    Charlize

    Another way to do the same :

    [vba]Sub DisableShortcutMenu()
    CommandBars("Cell").Enabled = False
    End Sub[/vba]

    To activate the menu again :

    [vba]
    Sub EnableShortcutMenu()
    CommandBars("Cell").Enabled = True
    End Sub
    [/vba]

    Charlize
    Last edited by Charlize; 10-02-2006 at 04:03 AM.

  3. #3
    VBAX Mentor
    Joined
    Jun 2004
    Posts
    363
    Location
    Original post change to assign Control numbers instead of named option. Controls(5) versus Controls("Insert")

    The following toggles the Insert option (on or off) for the Cell and Row right click menu based on the Row's current status.

    [vba]
    Option Explicit

    Sub toggleInsertRow()

    Dim insertState As Boolean

    insertState = Not CommandBars("Cell").Controls(5).Enabled

    CommandBars("Row").Controls(5).Enabled = insertState
    CommandBars("Cell").Controls(5).Enabled = insertState

    End Sub


    [/vba]

  4. #4
    VBAX Regular
    Joined
    Aug 2006
    Posts
    9
    Location
    You are great!
    Thank you!

Posting Permissions

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