-
Apr 23rd, 2022, 06:04 AM
#1
Thread Starter
New Member
[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 , 1 to insert the flow chart merge (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
-
Apr 27th, 2022, 03:18 AM
#2
Lively Member
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
-
Apr 27th, 2022, 04:09 AM
#3
Thread Starter
New Member
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)...
-
May 18th, 2022, 08:03 AM
#4
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|