Right click dialog

  • Thread starter Thread starter Adam
  • Start date Start date
A

Adam

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
 
Good morning Adam

This kind of thing can be done farily easily, although I don't thin
you can link in to the orignal Excel commands, you'll have to write (o
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 sta
in Excel - ie., it doesn't need to be invoked every time you restar
Excel. You will need to use something like the code supplied to remov
it. Additionally, this will only add things to the shortcut menu tha
appears when you right click over cells - this function is contex
sensitive.

HTH

Dominic
 
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)
 
Back
Top