Consulting

Results 1 to 6 of 6

Thread: Solved: Context Menu Control ID's

  1. #1
    VBAX Regular
    Joined
    Feb 2012
    Location
    United Kingdom, England
    Posts
    28
    Location

    Solved: Context Menu Control ID's

    Hi,

    Does anyone know of a list for all the right click Context MenuControl ID's?

    For example the save ID is:

    [VBA]ContextMenu.Controls.Add Type:=msoControlButton, ID:=3, before:=5[/VBA]

    I'm sure their probably is but my google search skills seem to be letting me down today.

    Thanks

    Ben

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Regular
    Joined
    Feb 2012
    Location
    United Kingdom, England
    Posts
    28
    Location
    Thanks for the reply.

    I was looking for a list of all possible controls... did I miss something in those two links?

    Thanks

    Ben

  4. #4
    VBAX Expert
    Joined
    Sep 2010
    Posts
    604
    Location
    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
    [vba]
    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
    [/vba]

  5. #5
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    Run this in a new workbook, it will list all your command bars and all their controls.

    [VBA]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[/VBA]

  6. #6
    VBAX Regular
    Joined
    Feb 2012
    Location
    United Kingdom, England
    Posts
    28
    Location
    Excellent, thats exactly what I was looking for

    Thankyou

Posting Permissions

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