+ Reply to Thread
Results 1 to 4 of 4

Right click dialog

  1. #1
    Adam
    Guest

    Right click dialog

    Morning All,

    I've just had a thought and wondered if it was possible.

    Is there a way I can add in functions to the right click dialog you get
    when you right click on a cell in Excel ?

    I was wondering if I could add in things like Freeze Pane or Centre
    Align etc.

    Anyone know if this is possible?


    Regards

    Adam

    Office 2003 Professional - Windows XP Pro SP2


  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Smile

    Good morning Adam

    This kind of thing can be done farily easily, although I don't think you can link in to the orignal Excel commands, you'll have to write (or record) your own macros and tie them into the code below.


    Sub Add()
    Dim NewSC As CommandBarControl
    Set NewSC = CommandBars("Cell").Controls.Add
    NewSC.Caption = "Adam's Shortcut"
    NewSC.OnAction = "Macro1"
    NewSC.BeginGroup = True
    End Sub

    Sub Remove()
    On Error Resume Next
    CommandBars("Cell").Controls("Adam's Shortcut").Delete
    End Sub

    Use the code below carefully. Once you have added a menu, it will stay in Excel - ie., it doesn't need to be invoked every time you restart Excel. You will need to use something like the code supplied to remove it. Additionally, this will only add things to the shortcut menu that appears when you right click over cells - this function is context sensitive.

    HTH

    DominicB

  3. #3
    Bob Phillips
    Guest

    Re: Right click dialog

    Hi Adam,

    Yes, it is easy, here is some sample code

    Public Sub addMenu()
    removeMenu 'just in case
    With Application.CommandBars("Cell")
    With .Controls.Add(Type:=msoControlButton, ID:=443)
    .BeginGroup = True
    End With
    End With
    End Sub


    Public Sub removeMenu()
    On Error Resume Next
    With Application.CommandBars("Cell")
    .Controls("Freeze Panes").Delete
    End With
    On Error GoTo 0
    End Sub



    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Adam" <[email protected]> wrote in message
    news:[email protected]...
    > Morning All,
    >
    > I've just had a thought and wondered if it was possible.
    >
    > Is there a way I can add in functions to the right click dialog you get
    > when you right click on a cell in Excel ?
    >
    > I was wondering if I could add in things like Freeze Pane or Centre
    > Align etc.
    >
    > Anyone know if this is possible?
    >
    >
    > Regards
    >
    > Adam
    >
    > Office 2003 Professional - Windows XP Pro SP2
    >




  4. #4
    David McRitchie
    Guest

    Re: Right click dialog

    Hi Adam,
    I like context menus, some more examples of Excel context menus
    Right Click Menus (Context Menus) in Excel
    http://www.mvps.org/dmcritchie/excel//rightclick.htm

    has four examples, I use the GetFormula one a lot, because it saves
    me a lot of typing for a quick example and reduces my typing mistakes.
    Though I may change the actual formula to GetFormulaD or GetFormat
    http://www.mvps.org/dmcritchie/excel/formula.htm




+ Reply to Thread

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