Results 1 to 4 of 4

Thread: [Ppt] How to execute commandbar control for triangle and double arrow?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2022
    Posts
    3

    [Ppt] How to execute commandbar control for triangle and double arrow?

    Hi everyone,
    I am trying to create 2 Powerpoint VBA Subs to insert shapes: 1 to insert the line arrow double Name:  im1.png
Views: 144
Size:  269 Bytes, 1 to insert the flow chart merge Name:  im2.png
Views: 196
Size:  413 Bytes (as both cannot be found in the commands to customize the ribbon for some reason)
    I managed to create the second one in Word but Powerpoint throws me an error: method of execute object failed. The first one while I found the control is not executing on neither application

    What should I do please? I noticed in Powerpoint both items under their respective commandbars have a "false" property in "enabled" (which I cannot force to true)

    Many thanks for your help,

    Code:
    Sub inverted_triangle()
    Application.CommandBars("Flowchart").Controls(22).Execute
    End Sub
    Code:
    Sub doublearrow()
    Application.CommandBars("Lines").Controls(3).Execute
    End Sub

  2. #2
    Lively Member
    Join Date
    May 2021
    Posts
    96

    Re: [Ppt] How to execute commandbar control for triangle and double arrow?

    Not sure how to go about adjusting the commandbars enabled property for either shape, but hopefully the following VBA code will work for you. If you paste them in a standard module, you should then be able to add them to the Ribbon, etc. Please let me know how it goes.

    Code:
    Sub AddArrow()
        Dim Arrow As Shape
        Set Arrow = ActiveSlide.Shapes.AddLine(BeginX:=200, BeginY:=100, EndX:=300, EndY:=200)
        With Arrow.Line
            .BeginArrowheadLength = msoArrowheadLengthMedium
            .BeginArrowheadStyle = msoArrowheadTriangle
            .BeginArrowheadStyle = msoArrowheadWidthMedium
            
            .EndArrowheadLength = msoArrowheadLengthMedium
            .EndArrowheadStyle = msoArrowheadTriangle
            .EndArrowheadStyle = msoArrowheadWidthMedium
        End With
        Set Arrow = Nothing
    End Sub
    
    Sub AddFlowChartMerge()
        Dim FlowChartMerge As Shape
        Set FlowChartMerge = ActiveSlide.Shapes.AddShape(Type:=msoShapeFlowchartMerge, Left:=10, Top:=10, Width:=50, Height:=100)
        
        Set FlowChartMerge = Nothing
    End Sub
    
    Function ActiveSlide() As Slide
        Set ActiveSlide = Application.ActiveWindow.View.Slide
    End Function

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2022
    Posts
    3

    Re: [Ppt] How to execute commandbar control for triangle and double arrow?

    Thanks for your answer Dan. Your code works but not exactly like mine was intended to: on yours position and size are pre-defined. Whereas using commandbar replicates the click on the button in the shapes menu where you can position the arrow/ triangle wherever you like (as opposed to adjusting the one created)...

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2022
    Posts
    3

    Re: [Ppt] How to execute commandbar control for triangle and double arrow?

    Up! An idea anyone please? I am "just" trying to replicate what an existing command is doing (to have the buttons in my personalized toolbar instead of having to dig into the shapes button)

Posting Permissions

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



Click Here to Expand Forum to Full Width