Skip to content

Commit 12153d8

Browse files
committed
Further improving handling shapes within groups
Most functions now support shapes within groups (subselection within a group). E.g. Align only selected shapes in a group
1 parent f8c2bbc commit 12153d8

File tree

8 files changed

+582
-196
lines changed

8 files changed

+582
-196
lines changed
8.19 KB
Binary file not shown.
9.63 KB
Binary file not shown.

src/Modules/ModuleAbout.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Attribute VB_Name = "ModuleAbout"
2424
Public InstrumentaVersion As String
2525

2626
Sub ShowAboutDialog()
27-
InstrumentaVersion = "1.04"
27+
InstrumentaVersion = "1.1"
2828
AboutDialog.Label1.Caption = "Instrumenta Powerpoint Toolbar v" & InstrumentaVersion
2929
AboutDialog.Show
3030
End Sub

src/Modules/ModuleObjectsAlignAndDistribute.bas

Lines changed: 346 additions & 108 deletions
Large diffs are not rendered by default.

src/Modules/ModuleObjectsRoundedCorners.bas

Lines changed: 87 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,59 +24,115 @@ Attribute VB_Name = "ModuleObjectsRoundedCorners"
2424
Sub 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

5588
End Sub
5689

5790
Sub 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

82138
End Sub

0 commit comments

Comments
 (0)