Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get VBE CommandBars Control ID number list

The following code is taken from this link.

https://forum.ozgrid.com/forum/index.php?thread/32040-minimize-vba-window-with-code/

Sub Macro1()

    Dim cbcTemp As CommandBarControl

    On Error Resume Next

    Set cbcTemp = Application.VBE.CommandBars.FindControl(ID:=752)
    If Not cbcTemp Is Nothing Then
        cbcTemp.Execute
    End If

    On Error GoTo 0

End Sub

The Control ID is 752 in given example above.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I need to understand what every ID number is doing.

Does anybody know how to get VBE CommandBars Control ID number list?

>Solution :

This will loop through all command bars and their controls. The names / descriptions of the controls aren’t great…

    Dim cbtemp As CommandBar
    Dim cbctemp As CommandBarControl
    
    For Each cbtemp In Application.VBE.CommandBars
        Debug.Print "command bar:", cbtemp.ID, cbtemp.Name
        For Each cbctemp In cbtemp.Controls
            Debug.Print cbctemp.ID, cbctemp.Caption, cbctemp.TooltipText
        Next
    Next

You may need to output this onto a sheet as mine exceeds the immediate windows display.

    Dim cbtemp As CommandBar
    Dim cbctemp As CommandBarControl
    
    Dim i As Long
    i = 1
    For Each cbtemp In Application.VBE.CommandBars
        Cells(i, 1).Value = cbtemp.ID
        Cells(i, 2).Value = cbtemp.Name
        For Each cbctemp In cbtemp.Controls
            i = i + 1
            Cells(i, 3).Value = cbctemp.ID
            Cells(i, 4).Value = cbctemp.Caption
            Cells(i, 5).Value = cbctemp.TooltipText
        Next
        i = i + 1
    Next
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading