Home Products Customers Tips VBA OfficeOne on Mac Contact us

GetMenuItems

The following routine gets all the menu items in the PowerPoint menu bar.

Sub GetMenuItems(ByVal MenuItems As Collection, _
    ByVal CBP As CommandBarPopup, ByVal Indent As Long)

    Dim CBC As CommandBarControl
    Dim IndentStr As String

    IndentStr = Space(Indent * 4)

    For Each CBC In CBP.Controls
        MenuItems.Add IndentStr + CBC.Caption
        If CBC.Type = msoControlPopup Then
            GetMenuItems MenuItems, CBC, Indent + 1
        End If
    Next
End Sub

Sub GetMenuBarItems(ByVal MenuItems As Collection)
    Dim CBC As CommandBarControl

    For Each CBC In CommandBars("Menu Bar").Controls
        GetMenuItems MenuItems, CBC, 0
    Next
End Sub

The following routine uses the GetMenuBarItems listed above

Sub PrintMenuBarItems()
    Dim MenuItems As New Collection
    Dim S As Variant

    GetMenuBarItems MenuItems

    For Each S In MenuItems
        Debug.Print S
    Next
End Sub


Home | Products | Tips | VBA | FAQ | Utilities | Disclaimer | Privacy Policy | Mac | Links | Contact us

Contact OfficeOne on email at officeone@officeoneonline.com. Copyright © 2001-2017 OfficeOne. All rights reserved.

page counter