View Full Version : Solved: Context Menu Control ID's
jaminben
03-10-2012, 10:59 AM
Hi,
Does anyone know of a list for all the right click Context MenuControl ID's?
For example the save ID is:
ContextMenu.Controls.Add Type:=msoControlButton, ID:=3, before:=5
I'm sure their probably is but my google search skills seem to be letting me down today.
Thanks
Ben
mancubus
03-10-2012, 11:22 AM
hi.
http://msdn.microsoft.com/en-us/library/gg469862.aspx
http://www.rondebruin.nl/contextmenu.htm
jaminben
03-10-2012, 03:19 PM
Thanks for the reply.
I was looking for a list of all possible controls... did I miss something in those two links?
Thanks
Ben
frank_m
03-10-2012, 09:41 PM
There's a list here for all menus names and ID's here for Excel 2000. As far as I know most or all are the same in Excel 2003
http://support.microsoft.com/kb/213552
Or you can get them with code
Sub Loop_Controls_get_NameAndID()
Dim ctrl As Object
'Right Click Menu for Cells
For Each ctrl In CommandBars("Cell").Controls
'Right Click Menu for Rows
'For Each ctrl In CommandBars("Row").Controls
MsgBox ctrl.Caption & Chr(13) & ctrl.ID
Next ctrl
End Sub
mikerickson
03-11-2012, 12:06 AM
Run this in a new workbook, it will list all your command bars and all their controls.
Sub test()
Dim rowNum As Long
Dim oneBar As CommandBar
rowNum = 0
Cells.ClearContents
For Each oneBar In Application.CommandBars
rowNum = rowNum + 1
Cells(rowNum, 1) = oneBar.Name
WriteControlNames oneBar, rowNum, 1
Next oneBar
End Sub
Sub WriteControlNames(ByRef Container As Object, ByRef rNum As Long, ByVal cNum As Long)
Dim CCount As Long, i As Long
CCount = 0: On Error Resume Next
CCount = Container.Controls.Count: On Error GoTo 0
If 0 < CCount Then
For i = 1 To CCount
rNum = rNum + 1
With Container.Controls(i)
Cells(rNum, cNum + 1).Value = .Id & "-" & .Caption
End With
WriteControlNames Container.Controls(i), rNum, cNum + 1
Next i
End If
End Sub
jaminben
03-11-2012, 02:41 AM
Excellent, thats exactly what I was looking for :thumb
Thankyou
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.