Supercharge your PowerPoint productivity with
Supercharge your PPT Productivity with PPTools - Click here to learn more.

PPTools

Image Export converts PowerPoint slides to high-quality images.

PPT2HTML exports HTML even from PowerPoint 2010 and 2013, gives you full control of PowerPoint HTML output, helps meet Section 508 accessibility requirements

Merge Excel data into PowerPoint presentations to create certificates, awards presentations, personalized presentations and more

Resize your presentations quickly and without distortion

Language Selector switches the text in your presentation from one language to another

FixLinks prevents broken links when you distribute PowerPoint presentations

Shape Styles brings styles to PowerPoint. Apply complex formatting with a single click.

Prep4PDF preserves interactivity in PowerPoint presentations when you convert to PDF

Add a popup toolbar

This sample code shows you how to create and display a popup toolbar that uses both built-in PowerPoint methods (the Save button on the toolbar) and calls your own routines (the Do Stuff) button.

Run CreateThePopup to create the popup menu, then call or manually run DisplayMyPopup to display and use the popup menu.

Sub CreateThePopup()

    Dim oCmdBar As CommandBar
    Dim oCtrl As CommandBarControl

    ' delete the popup if it already exists
    For Each oCmdBar In Application.CommandBars
        If UCase(oCmdBar.Name) = UCase("myPopup") Then
            oCmdBar.Delete
            Debug.Print "Found/Deleted existing popup"
        Else
            Debug.Print oCmdBar.Name
        End If
    Next ' commandbar

    Set oCmdBar = Application.CommandBars.Add(Name:="myPopup", Position:=msoBarPopup)

    With oCmdBar
        ' Add a SAVE button
        Set oCtrl = .Controls.Add(Type:=msoControlButton, Id:=3)

        'add a Do Stuff button that calls your doStuff subroutine (see below)
        Set oCtrl = .Controls.Add(Type:=msoControlButton)
         With oCtrl
             .FaceId = 10
             .Caption = "Do stuff"
             .OnAction = "doStuff"
         End With

    End With

End Sub

Sub DisplayMyPopup()
' Call this sub to display the popup
    Application.CommandBars("myPopUp").ShowPopup
End Sub

Sub doStuff()
    MsgBox "I did stuff"
End Sub

OK, SuperEgo, where did ID come from?

How did we know what ID to use in this line above?

Set oCtrl = .Controls.Add(Type:=msoControlButton, Id:=3)

This little bit of code will list all of the available IDs for you:

Sub ListIDs()

  Dim oCtl as CommandBarControl
  Dim oCmdBar as CommandBar
  Dim sFileName as String
  Dim iFileNum as Integer

  ' Change this if you'd rather put the file elsewhere
  sFileName = "C:\temp\PowerPointIDs.TXT"

  iFileNum = FreeFile()
  Open sFileName For Output As iFileNum

  For Each oCmdBar In Application.CommandBars
    Print #iFileNum, oCmdBar.Name
    For Each oCtl In oCmdBar.Controls
      Print #iFileNum, oCtl.Id & vbTab & oCtl.Caption
    Next
  Next

  Close iFileNum

End Sub


Did this solve your problem? If so, please consider supporting the PPT FAQ with a small PayPal donation.
Page copy protected against web site content infringement by Copyscape Contents © 1995 - 2015 Stephen Rindsberg, Rindsberg Photography, Inc. and members of the MS PowerPoint MVP team. You may link to this page but any form of unauthorized reproduction of this page's contents is expressly forbidden.
Español    Deutsch    Français    Português    Italiano    Nederlands    Greek    Japanese    Korean    Chinese

Supercharge your PPT Productivity with PPTools

content authoring & site maintenance by
Friday, the automatic faq maker (logo)
Friday - The Automatic FAQ Maker

Add a popup toolbar
http://www.pptfaq.com/FAQ00768_Add_a_popup_toolbar.htm
Last update 07 June, 2011
Created: