VBA:如何在选择后连接powerpoint形状

时间:2017-08-21 10:07:03

标签: vba powerpoint

我只想在选择后连接2个方格。

我的代码不起作用,无法查看如何修复它:

Sub ConnectSelectedShapes()

Dim shpFirst As Shape
Dim shpSecond As Shape

Dim shpShapes As Shapes

Set shapesRange = ActiveWindow.Selection.ShapeRange

Set shpFirst = shapesRange(1)
Set shpSecond = shapesRange(2)

With shpShapes.AddConnector(Type:=msoConnectorCurve, BeginX:=0, _
        BeginY:=0, EndX:=100, EndY:=100).ConnectorFormat

    .BeginConnect ConnectedShape:=shpFirst, ConnectionSite:=1
    .EndConnect ConnectedShape:=shpSecond, ConnectionSite:=1
    .Parent.RerouteConnections

End With

End Sub

1 个答案:

答案 0 :(得分:0)

您已经明确了shpShapes,但是您还没有定义它......

Set shpShapes = ActiveWindow.View.Slide.Shapes

当然,在运行代码之前,您需要确保选择了2个形状。

希望这有帮助!