@@ -24,59 +24,115 @@ Attribute VB_Name = "ModuleObjectsRoundedCorners"
2424Sub ObjectsCopyRoundedCorner ()
2525 Dim SlideShape As PowerPoint .Shape
2626 Set myDocument = Application.ActiveWindow
27+ Dim ShapeRadius As Single
2728
2829 If Not myDocument.Selection.Type = ppSelectionShapes Then
2930 MsgBox "No shapes selected."
31+
32+ ElseIf myDocument.Selection.HasChildShapeRange Then
33+
34+ If Application.ActiveWindow.Selection.ChildShapeRange(1 ).Adjustments.Count > 0 Then
35+
36+ ShapeRadius = myDocument.Selection.ChildShapeRange(1 ).Adjustments(1 ) / (1 / (myDocument.Selection.ChildShapeRange(1 ).Height + myDocument.Selection.ChildShapeRange(1 ).Width))
37+
38+ If myDocument.Selection.ChildShapeRange(1 ).Adjustments.Count > 1 Then
39+ ShapeRadius2 = myDocument.Selection.ChildShapeRange(1 ).Adjustments(2 ) / (1 / (myDocument.Selection.ChildShapeRange(1 ).Height + myDocument.Selection.ChildShapeRange(1 ).Width))
40+ End If
41+
42+ For Each SlideShape In ActiveWindow.Selection.ChildShapeRange
43+ With SlideShape
44+ .AutoShapeType = myDocument.Selection.ChildShapeRange(1 ).AutoShapeType
45+ .Adjustments(1 ) = (1 / (SlideShape.Height + SlideShape.Width)) * ShapeRadius
46+ If myDocument.Selection.ChildShapeRange(1 ).Adjustments.Count > 1 Then
47+ .Adjustments(2 ) = (1 / (SlideShape.Height + SlideShape.Width)) * ShapeRadius2
48+ End If
49+ End With
50+ Next
51+
52+ End If
53+
3054 Else
31-
32- Dim ShapeRadius As Single
33- If Application.ActiveWindow.Selection.ShapeRange(1 ).Adjustments.Count > 0 Then
34-
35- ShapeRadius = myDocument.Selection.ShapeRange(1 ).Adjustments(1 ) / (1 / (myDocument.Selection.ShapeRange(1 ).Height + myDocument.Selection.ShapeRange(1 ).Width))
36-
37- If myDocument.Selection.ShapeRange(1 ).Adjustments.Count > 1 Then
38- ShapeRadius2 = myDocument.Selection.ShapeRange(1 ).Adjustments(2 ) / (1 / (myDocument.Selection.ShapeRange(1 ).Height + myDocument.Selection.ShapeRange(1 ).Width))
39- End If
40-
41- For Each SlideShape In ActiveWindow.Selection.ShapeRange
42- With SlideShape
43- .AutoShapeType = myDocument.Selection.ShapeRange(1 ).AutoShapeType
44- .Adjustments(1 ) = (1 / (SlideShape.Height + SlideShape.Width)) * ShapeRadius
55+
56+ For i = 1 To Application.ActiveWindow.Selection.ShapeRange.Count
57+
58+ If Application.ActiveWindow.Selection.ShapeRange(i).Type = msoGroup Then
59+ MsgBox "One of the selected shapes is a group."
60+ Exit Sub
61+ End If
62+
63+ Next i
64+
65+
66+ If Application.ActiveWindow.Selection.ShapeRange(1 ).Adjustments.Count > 0 Then
67+
68+ ShapeRadius = myDocument.Selection.ShapeRange(1 ).Adjustments(1 ) / (1 / (myDocument.Selection.ShapeRange(1 ).Height + myDocument.Selection.ShapeRange(1 ).Width))
69+
4570 If myDocument.Selection.ShapeRange(1 ).Adjustments.Count > 1 Then
46- . Adjustments(2 ) = (1 / (SlideShape. Height + SlideShape. Width)) * ShapeRadius2
71+ ShapeRadius2 = myDocument.Selection.ShapeRange( 1 ). Adjustments(2 ) / (1 / (myDocument.Selection.ShapeRange( 1 ). Height + myDocument.Selection.ShapeRange( 1 ). Width))
4772 End If
48- End With
49- Next
50-
51- End If
52-
73+
74+ For Each SlideShape In ActiveWindow.Selection.ShapeRange
75+ With SlideShape
76+ .AutoShapeType = myDocument.Selection.ShapeRange(1 ).AutoShapeType
77+ .Adjustments(1 ) = (1 / (SlideShape.Height + SlideShape.Width)) * ShapeRadius
78+ If myDocument.Selection.ShapeRange(1 ).Adjustments.Count > 1 Then
79+ .Adjustments(2 ) = (1 / (SlideShape.Height + SlideShape.Width)) * ShapeRadius2
80+ End If
81+ End With
82+ Next
83+
84+ End If
85+
5386 End If
5487
5588End Sub
5689
5790Sub ObjectsCopyShapeTypeAndAdjustments ()
5891 Dim SlideShape As PowerPoint .Shape
5992 Set myDocument = Application.ActiveWindow
93+ Dim AdjustmentsCount As Long
94+ Dim ShapeCount As Long
6095
6196 If Not myDocument.Selection.Type = ppSelectionShapes Then
6297 MsgBox "No shapes selected."
98+
99+ ElseIf myDocument.Selection.HasChildShapeRange Then
100+
101+ For ShapeCount = 2 To ActiveWindow.Selection.ChildShapeRange.Count
102+
103+ myDocument.Selection.ChildShapeRange(ShapeCount).AutoShapeType = myDocument.Selection.ChildShapeRange(1 ).AutoShapeType
104+
105+ For AdjustmentsCount = 1 To myDocument.Selection.ChildShapeRange(1 ).Adjustments.Count
106+
107+ myDocument.Selection.ChildShapeRange(ShapeCount).Adjustments(AdjustmentsCount) = myDocument.Selection.ChildShapeRange(1 ).Adjustments(AdjustmentsCount)
108+
109+ Next AdjustmentsCount
110+
111+ Next ShapeCount
112+
63113 Else
64-
65- Dim AdjustmentsCount As Long
66- Dim ShapeCount As Long
67-
68- For ShapeCount = 2 To ActiveWindow.Selection.ShapeRange.Count
69114
70- myDocument.Selection.ShapeRange(ShapeCount).AutoShapeType = myDocument.Selection.ShapeRange(1 ).AutoShapeType
115+ For i = 1 To Application.ActiveWindow.Selection.ShapeRange.Count
116+
117+ If Application.ActiveWindow.Selection.ShapeRange(i).Type = msoGroup Then
118+ MsgBox "One of the selected shapes is a group."
119+ Exit Sub
120+ End If
121+
122+ Next i
71123
72- For AdjustmentsCount = 1 To myDocument .Selection.ShapeRange( 1 ).Adjustments .Count
124+ For ShapeCount = 2 To ActiveWindow .Selection.ShapeRange.Count
73125
74- myDocument.Selection.ShapeRange(ShapeCount).Adjustments(AdjustmentsCount) = myDocument.Selection.ShapeRange(1 ).Adjustments(AdjustmentsCount)
126+ myDocument.Selection.ShapeRange(ShapeCount).AutoShapeType = myDocument.Selection.ShapeRange(1 ).AutoShapeType
75127
76- Next AdjustmentsCount
128+ For AdjustmentsCount = 1 To myDocument.Selection.ShapeRange(1 ).Adjustments.Count
129+
130+ myDocument.Selection.ShapeRange(ShapeCount).Adjustments(AdjustmentsCount) = myDocument.Selection.ShapeRange(1 ).Adjustments(AdjustmentsCount)
131+
132+ Next AdjustmentsCount
133+
134+ Next ShapeCount
77135
78- Next ShapeCount
79-
80136 End If
81137
82138End Sub
0 commit comments