Powerpoint Add-In Own Menu

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi Everyone!
I hope you can help me with the following problem. I am getting a little
'frustrated'...

Here is what I wanted to do:

I have written some macros to use in powerpoint. I want to convert these
macros to add-in so that I can easily install the macros on other computers.
I have several macros (5, that is) and I was hoping to place them in some
kind of sub-menu, say for example in the tools menu of windows. Or, even
better, create an extra menu, named 'my macros', to the right of the
Help-menu of Powerpoint.

My Problem: I don't know the code and I couldn't find any examples on the web.
Can somebody please, please, please help me!!!!!!!

I would be great sb. could help me with the code, ie. give me a full example
code
The name of my macros are: blue, green, human, marc, paint.

I really really appreciate your help! Thank you sooooo much!!
Marc
 
Are you using PPT2003, have you searched "Add menu" in PPT VB help?
Some topics maybe helpful to you : OLEMenuGroup Property |Adding and
Displaying Shortcut Menus|Adding and Managing Menu Bars and Menu Items
etc.

Best regards,
KPP
 
Marc,

This is sample code to create your own toolbar and menu items.

Sub CreatePopupToolbarExample()
Dim CustomToolBar As CommandBar
Dim MainCustomBar As CommandBarPopup
Dim SubMenuItem As CommandBarButton
Dim SubMenuPopUp As CommandBarPopup
Dim SubMenuPopUpItem As CommandBarButton
Dim DropDownList As CommandBarControl

Dim strToolBar As String
Dim iCount As Integer


' Replace "My Toolbar" with a name
' you want to use for your toolbar.
strToolBar = "My Toolbar"


' Create and display the Toolbar.
Set CustomToolBar = CommandBars.Add(Name:=strToolBar, _
Position:=msoBarFloating)
CustomToolBar.Visible = True


' Create Main PopUp Menu on Toolbar.
Set MainCustomBar = CustomToolBar.Controls.Add(Type:=msoControlPopup)
MainCustomBar.Caption = "Main Menu"
' Create Dropdown list on toolbar
Set DropDownList = CustomToolBar.Controls.Add(Type:=msoControlDropdown)


' Add a Menu Button and a Popup
With MainCustomBar.Controls
Set SubMenuItem = .Add(Type:=msoControlButton)
Set SubMenuPopUp = .Add(Type:=msoControlPopup)
End With


' Set properties for the sub button and popup menus.
With SubMenuItem
.Caption = "Sub Menu Item"
.Style = msoButtonCaption
.OnAction = "MenuEvents" ' <- Macro to run when clicked.
End With


With SubMenuPopUp
.Caption = "Sub Menu Popup"
' This optional can be used to invoke macro which toggles
' the state of child controls.
.OnAction = "MenuEvents"
End With


' Add item to Sub Menu
With SubMenuPopUp.Controls
Set SubMenuPopUpItem = .Add(Type:=msoControlButton)
End With


With SubMenuPopUpItem
.Caption = "Sub Menu Popup Item"
.OnAction = "MenuEvents" ' <- Macro to run when clicked.
End With


' Create a combo box which lists the options.


With DropDownList
.AddItem "Choice A"
.AddItem "Choice B"
.Caption = "Choices"
.TooltipText = "Select choice from the list"
.Width = 120
' default value to show
.ListIndex = 1
.OnAction = "MenuEvents"
End With


End Sub


Sub MenuEvents()
'Handler for the event when user clicks on the toolbar options
Dim cmdBCtl As CommandBarControl
Set cmdBCtl = Application.CommandBars.ActionControl
' Determine the caption of the control that was clicked.
Select Case cmdBCtl.Caption


Case "Choices"
With cmdBCtl
Select Case .ListIndex
Case 1
MsgBox "You selected 1st item in dropdown list", _
vbInformation, "Menu Choice"
Case 2
MsgBox "You selected 2nd item in dropdown list", _
vbInformation, "Menu Choice"
End Select
End With
Case "Sub Menu Item"
MsgBox "You selected item:" & "Sub Menu Item", _
vbInformation, "Menu Choice"


Case "Sub Menu Popup"
' Do preprocessing, adding/deleting/
' enabling/disabling child items in the popup.
Debug.Print "Sub Menu Popup"
Case "Sub Menu Popup Item"
MsgBox "You selected item in the popup", _
vbInformation, "Menu Choice"
End Select
End Sub


Sub RemoveMenu()
On Error Resume Next
Application.CommandBars("My Toolbar").Delete
End Sub


' ----- End Of Code -----
 
Shyam Pillai, your "my hero" !

Your code was exactly what I was looking for!!! + Thank you very much for
the quick reply!

Wow, I am impressed...

Thank you very much!!!

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top