Henk Straten
Henk Straten

Reputation: 1447

Create the position of an inserted graph in powerpoint

I am trying to write VBA code that can reproduce the following shape:

enter image description here

I wrote a piece of code that can create the shape:

Sub InsertShape()

Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddShape Type:=msoShapeChevron, _
    Left:=50, Top:=50, Width:=100, Height:=200


End Sub

However now I am looking for a way so I can adjust the width and height and move it to specific position. If I click on the shape (see highlighted areas) I see the target shape has the following values:

Height: 6:51 With: 7,07

Horizontal position: 11,16 Vertical position: 4,52

Any feedback on what I should add to the code so the shape is in the right position (+ correct width an height).

Upvotes: 0

Views: 80

Answers (1)

Steve Rindsberg
Steve Rindsberg

Reputation: 14809

Use the .Height/.Width/.Left/.Top parameters to adjust the size and position of the shape (note that the values are in points; 28.35 points/cm or 72 points/inch).

Use the shape's .Adjustments(1) property to modify the characteristics of the shape. Start with a value of approximately .2 to get the kind of shape you're after.

Sub InsertShape()
' ALWAYS Dim your variables
Dim myDocument as Slide
Dim oSh as Shape

Set myDocument = ActivePresentation.Slides(1)
Set oSh = myDocument.Shapes.AddShape Type:=msoShapeChevron, _
    Left:=50, Top:=50, Width:=100, Height:=200
With oSh
   .Adjustments(1) = .2
   ' Change other shape properties here too if you wish
End With

End Sub

Upvotes: 1

Related Questions