none
Powerpoint: Connect to Rectangle with a line RRS feed

  • Question

  • Greetings,

    I have try with VB in Visual Studio to connect two Rectangles with a line, and then stick the line on the rectangle, so that if I move the rectangele the line stretches:

    Dim Shape1 As PPApp.Shape = Nothing
    Dim Shape2 As PPApp.Shape = Nothing

    Shape1 = PPFolie.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, X, Y, w, h)
    Shape2 = PPFolie.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, X + 50, Y + 50, w, h)

    PFolie.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorElbow, X, Y, X + 50, Y + 50)
    Shape1.ConnectorFormat.BeginConnect(Shape1, 1)
    Shape2.ConnectorFormat.BeginConnect(Shape2, 1)

    But the line is not connected to the rectangles.

    Has anyone an idea?

    Thank you!

         Michael

    Sunday, December 22, 2013 10:16 PM

Answers

  • Hi,

    According to your description, you want to add a line as a connector between two rectangles in PowerPoint.

    I edit your code below and it work well. You should set the ConnectorFormat.BeginConnect method in a correct way.

    Dim Shape1 As PPApp.Shape = Nothing
    Dim Shape2 As PPApp.Shape = Nothing
    Dim oConnector As Object
    Shape1 = PPFolie.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, X, Y, w, h)
    Shape2 = PPFolie.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, X + 50, Y + 50, w, h)
    oConnector = PPFolie.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorElbow, X, Y, X + 50, Y + 50)
    oConnector.ConnectorFormat.BeginConnect(Shape1, 1)
    oConnector.ConnectorFormat.EndConnect(Shape2, 1)

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Michael-Markus Friday, December 27, 2013 11:42 AM
    Monday, December 23, 2013 9:37 AM
    Moderator

All replies

  • Hi,

    According to your description, you want to add a line as a connector between two rectangles in PowerPoint.

    I edit your code below and it work well. You should set the ConnectorFormat.BeginConnect method in a correct way.

    Dim Shape1 As PPApp.Shape = Nothing
    Dim Shape2 As PPApp.Shape = Nothing
    Dim oConnector As Object
    Shape1 = PPFolie.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, X, Y, w, h)
    Shape2 = PPFolie.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, X + 50, Y + 50, w, h)
    oConnector = PPFolie.Shapes.AddConnector(Microsoft.Office.Core.MsoConnectorType.msoConnectorElbow, X, Y, X + 50, Y + 50)
    oConnector.ConnectorFormat.BeginConnect(Shape1, 1)
    oConnector.ConnectorFormat.EndConnect(Shape2, 1)

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Michael-Markus Friday, December 27, 2013 11:42 AM
    Monday, December 23, 2013 9:37 AM
    Moderator
  • Thank you for the code!

    I have an additional question:

    Now I have draw a line from one sharp to another shape.

    If now the end of the line (x/y coordinate) is not x/y coordinate of a Connector on the shape, who can I define an additional Connector of the shape?

    Thank you!

        Michael

    Friday, December 27, 2013 11:56 AM
  • Hi Michael,

    What do you mean by "the end of the line (x/y coordinate) is not x/y coordinate of a Connector on the shape"?

    Since your initial question has been resolved, in order to involve more partners of this community to share their knowledge or learn from your interaction with us, I suggest you to post a new thread in the forum. 

    Thanks for your understanding.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 31, 2013 3:23 AM
    Moderator