Sunday, July 20, 2008

Creating Menu’s and CommandBars in Powerpoint using VBA

Add a powerpoint menu item using VBA

The following code helps in creating a menu in active menu bar.

Sub Add_New_Menu_ITem_Powerpoint()

Dim oMenuBar

Dim oMenu As CommandBarPopup

Dim oCtrl As CommandBarControl

oMenuBar = Application.CommandBars.ActiveMenuBar

oMenu = oMenuBar.Controls.Add(Type:=msoControlPopup, Temporary:=True)

oMenu.Caption = "VBADUD Menu"

oMenu.Enabled = True

oMenu.DescriptionText = "Sample Menu Created for VBADud Example"

oCtrl = oMenu.Controls.Add(Type:=msoControlButton)

oCtrl.Caption = "Set Font"

End Sub

oMenu As CommandBarPopup represents a pop-up control on a command bar. The use of CommandBars in some Microsoft Office applications has been superseded by the new Ribbon user interface.

1 comment:

  1. Anonymous5:47 AM

    Hi,
    there are small errors. Here is a fixed version:
    Sub Add_New_Menu_ITem_Powerpoint()

    Dim oMenuBar
    Dim oMenu As CommandBarPopup
    Dim oCtrl As CommandBarControl

    Set oMenuBar = Application.CommandBars.ActiveMenuBar
    Set oMenu = oMenuBar.Controls.Add(Type:=msoControlPopup, Temporary:=True)
    oMenu.Caption = "VBADUD Menu"
    oMenu.Enabled = True
    oMenu.DescriptionText = "Sample Menu Created for VBADud Example"

    Set oCtrl = oMenu.Controls.Add(Type:=msoControlButton)
    oCtrl.Caption = "Set Font"

    End Sub

    ReplyDelete

StumbleUpon
Share on Facebook
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.