Consulting

Results 1 to 5 of 5

Thread: Toolbar for add-ins created

  1. #1

    Toolbar for add-ins created

    Hello John,

    I am using PowerPoint 2010, I have gathered a few macros code given by you and have created addins for the same. I wanted to gather all the addin in a toolbar, but I have two set of code for the toolbar which works perfectly when used separately, but I want to merge both of them, so that I have combination of button and drop down button in the toolbar. Below are the two set of codes.

    Set 1--------------------------
    Sub Auto_Open1()
        Dim oToolbar As CommandBar
        Dim oButton As CommandBarButton
        Dim MyToolbar As String
    
    
        MyToolbar = "Toolbar"
    
    
        On Error Resume Next
    
    
        Set oToolbar = CommandBars.Add(Name:=MyToolbar, _
            Position:=msoBarFloating, Temporary:=True)
        If err.Number <> 0 Then
              Exit Sub
        End If
    
    
        On Error GoTo errorhandler
    
    
    'Button 1 ====================================
    
    
        Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    
    
        With oButton
             .DescriptionText = "Description"
             .Caption = "Caption"
             .OnAction = "MacroName"
             .Style = msoButtonIconAndCaption
             .FaceId = ###
        End With
        
    'Button 2 ====================================
    
    
        Set oButton = oToolbar.Controls.Add(Type:=msoControlButton)
    
    
        With oButton
             .DescriptionText = "Description"
             .Caption = "Caption"
             .OnAction = "MacroName"
             .Style = msoButtonIconAndCaption
             .FaceId = ###
        End With
    
    
        oToolbar.Top = 150
        oToolbar.Left = 150
        oToolbar.Visible = True
    
    
    NormalExit:
        Exit Sub 
    
    
    errorhandler:
         'Just in case there is an error
         MsgBox err.Number & vbCrLf & err.Description
         Resume NormalExit:
         
    End Sub


    Set 2--------------------------
    Sub Auto_Open2()
        Dim myMainMenuBar As CommandBar
        Dim myCustomMenu As CommandBarControl
        Dim myTempMenu As CommandBarControl
         
         
        On Error Resume Next
        Application.CommandBars.ActiveMenuBar.Controls("This name").Delete
        On Error GoTo errorhandler
        Set myMainMenuBar = Application.CommandBars.ActiveMenuBar
         
        
        Set myCustomMenu = myMainMenuBar.Controls.Add(Type:=msoControlPopup, _
        before:=3)
        myCustomMenu.Caption = "This name"
    
    
    'Button 1 ====================================
    
    
        Set myTempMenu = myCustomMenu.Controls.Add(Type:=msoControlButton)
        With myTempMenu
             
            .Caption = "Whatever"
            .OnAction = "Whatever"
        End With
    
    
    'Button 2 ====================================
         
        Set myTempMenu = myCustomMenu.Controls.Add(Type:=msoControlButton)
        With myTempMenu
             
            .Caption = "Something else"
            .OnAction = "Something_else"
        End With
         
         
         'repeat these as often as you wish
         
        Exit Sub
    errorhandler:
        MsgBox "Sorry there's been an error " & err.Description, vbCritical
    End Sub




    Please can you take a look at the code and help me merge both sets into one.

    Thanks,
    Rafael
    Last edited by SamT; 10-17-2013 at 06:25 AM. Reason: Formatted Code with # button

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,094
    Location
    This is old legacy code which is not needed or sensible in 2010.

    Create your pptm file calling the macros myMacro1, myMacro2 etc. Save and close PPT

    Download the Custom UI EDitor tool

    Use it to open the pptm file

    Insert > Office 2007 Custum UI Part (NOT 2010)

    Paste in the code below and save

    Open the pptm in PowerPoint

    code to paste

    <customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <ribbon startFromScratch="false">
    <tabs>
    <tab id="customTab1" label="Label Name" >
    <group id="Group1" label="Label Name" >
    <menu id="menu2" imageMso="TableIndexes" size="large" label="Macros" >
    <button id="MenubuttA" label="Macro1" imageMso="AppointmentColor1" onAction="myMacro1"/>
    <button id="MenubuttB" label="Macro2" imageMso="AppointmentColor2" onAction="myMacro2"/>
    </menu>
    <button id="customButton1" label="Macro3" imageMso="AppointmentColor3" onAction ="myMacro3" />
    <button id="customButton2" label="Macro4" imageMso="AppointmentColor4" onAction ="myMacro4" />
    </group>
    </tab>
    </tabs>
    </ribbon>
    </customUI>

    Example file
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    That is really great John, had never used Custom UI Editor tool earlier, just downloaded and it was really easy to use. It was really very helpful.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,729
    Location
    There is an Office 2007 Ribbon UI forum here with a lot of information and tips to using the Fluent CustomUI interface

    Also a lot of 2010 material and links also


    Paul

  5. #5
    VBAX Newbie
    Joined
    Oct 2013
    Posts
    5
    Location
    Working Great for me, Tnx for share!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •