Reputation: 81
I am trying to run a script in Powerpoint module to convert all selected rectangle shape into rounded shape, below are the script which I got online but its converting only the first selected rectangle
This for the powerpoint 2016
Sub SetShapeRoundingRadius()
Dim oShape As Shape
Dim sngRadius As Single ' Radius size in points
Set oShape = ActiveWindow.Selection.ShapeRange(1)
sngRadius = 0.1
With oShape
oShape.AutoShapeType = msoShapeRoundedRectangle
.Adjustments(1) = sngRadius
End With
Set oShape = Nothing
End Sub
Upvotes: 0
Views: 1026
Reputation: 1615
This snippet will convert the selected objects. This version applies a loop to process all items returned by Selection.ShapeRange
.
Dim oShape As Shape
Dim sngRadius As Single ' Radius size in points
sngRadius = 0.1
For Each oShape In ActiveWindow.Selection.ShapeRange
With oShape
oShape.AutoShapeType = msoShapeRoundedRectangle
.Adjustments(1) = sngRadius
End With
Next
Set oShape = Nothing
Upvotes: 4
Reputation: 6654
Maybe Try this:
Sub SetSdasdhapeRoundingRadius()
Dim oShape As Shape
Dim sngRadius As Single ' Radius size in points
For Each shp In ActivePresentation.Slides(1).Shapes
shp.Select
If InStr(1, shp.Name, "Rectangle") > 0 Then
Set oShape = ActiveWindow.Selection.ShapeRange(1)
sngRadius = 0.1
With oShape
oShape.AutoShapeType = msoShapeRoundedRectangle
.Adjustments(1) = sngRadius
End With
Set oShape = Nothing
End If
Next
End Sub
Upvotes: 0