Adding items to right-click menu

C

Cumberland

Hi.

I have written a short macro to add items to the right-click menu, bu
am having difficulty finding the right ID numbers. So far, I hav
managed to add "Paste Values" and "Paste Formatting", as below:

Sub AddItems()

'Paste Values
Application.CommandBars("cell").Controls.Add Type:=msoControlButton
ID:=370, before:=5

'Paste Formatting
Application.CommandBars("cell").Controls.Add Type:=msoControlButton
ID:=369, before:=5

End Sub

I also want to add the following:


- Paste Formulas
- Paste Comments


But I don't know the relevant ID numbers! Please can anyone tell m
what they are?

Thanks
 
C

Cumberland

Thanks Simon, much appreciated, but unfortunately they haven't answered
my question.

You'll notice that the ID numbers I already have, 369 and 370, aren't
actually listed in the ID numbers link, so what I really need are
absolutely EVERY single ID number possible and what they do. I've had a
scan around Microsoft's website, but they aren't there.

I could try going through every ID in the macro until I find the right
ones, but that could take a LONG time!!!
 
S

Simon Lloyd

Sorry thats the best i could do, perhaps send mail to microsoft and
ask?

Worth a go!

Regards,
Simon
 
R

RB Smissaert

You don't need any ID's to add to the right-click menu:

With Application.CommandBars("Cell")
With .Controls.Add(Type:=msoControlButton)
.BeginGroup = True
.Caption = "Change text to numbers in selected sheet range"
.OnAction = "MakeNumbers"
.FaceId = 399
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Change formula's to values"
.OnAction = "FormulasToValues"
.FaceId = 385
End With
End With

etc.

RBS
 
R

RB Smissaert

Sorry, ignore this message. I realize you are dealing with built-in actions
where this is different.
Still, maybe you could make macro's that do these built-in actions and do it
as posted.

RBS
 
N

NickHK

You can generate all the data yourself. depending exactly what you need,
something aloong these lines:
Private Sub CommandButton1_Click()
Dim cmdBar As CommandBar
Dim cmdBarCtrl As CommandBarControl

For Each cmdBar In CommandBars
Debug.Print cmdBar.Index, cmdBar.Name
For Each cmdBarCtrl In cmdBar.Controls
Debug.Print , cmdBarCtrl.ID, cmdBarCtrl.Caption
Next
Next
End Sub

NickHK
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top