PDA

View Full Version : Fixing a connector in PowerPoint VBA



CuriosityBug
09-01-2019, 06:52 AM
Hello all,


I am trying to eliminate jogs of connector that has occurred in slides. I tried following approach but this is not helping in anyway. Please help: pray2:


Problem illustration:


If the rectangles are moved, then the connectors attached to that is effected. The connector ( arrow head elbow connector) has a bend or is inclined, I am trying to fix this so that process chart looks neat and oriented. I would like to know the functionality/method to decrease the size/shrink the connector and run macros without any manual 'selection' of shapes/objects. The macro itself should identify the place where connectors are disoriented and fix them. something like this, the connector that is pointed with red arrow is the connector to be fixed and blue arrow is expected result.




Code I tried: To do this for all connector you can just loop all the connectors and check or adjust the Y positions. Which should move the left end to the same as the right end


Sub SetConnectors()
Dim osld As Slide, oshp As Shape
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.Type = msoConnectorStraight Then
oshp.BeginY = oshp.EndY


End If
Next oshp
Next osld
End Sub

John Wilson
09-01-2019, 07:52 AM
This is a long standing bug with elbow connectors. Do you need elbows?

If you select the connector and check SIZE you will see the height is not exactly zero. Set it to zero can help (temporarily) but might also disconnect it. If you try to do this in code the test you are using will not work. Connector (and all shapes) are Type 1. You would need to further check the oshp.Autoshape.Type for -2 which is still all lines. A possible test is to check the NAME

If oshp.Name Like "*Connector*" Then but this will of course fail if the name is changed.

CuriosityBug
09-01-2019, 09:12 AM
Yes, I need elbow connectors. Is there no way to solve this bug?:)

John Wilson
09-04-2019, 06:21 AM
I don't know any permanent way. Setting Height to zero can help but it doesn't "stick"