Name

workbook.CommandBars

Synopsis

Returns a collection containing the command bars associated with a workbook. Returns Nothing if the workbook has no command bars. The following code displays the name of visible workbook-level command bars:

If Not (ThisWorkbook.CommandBars Is Nothing) Then
    For Each bar In ThisWorkbook.CommandBars
        If bar.Visible Then _
          Debug.Print bar.Name
    Next
Else
    Debug.Print "No workbook-level command bars."
End If

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.