Hi all.
Below is a simple PowerClip macro I’m using to powerclip drop shadows. It works well enough but I would like to add an If condition to Exit Sub if the right number of shapes are not selected.Because drop shadows read as two objects, and grouping several read as one object, I need an If condition count for 2 ‘or’ 3 objects. The bracketed example below is what I’m using now, but this only works on the container and a single drop shadow (3 objects in total).I know this must be simple, and I’ve figured out more difficult issues, but I cannot find anywhere that solves this problem. If anyone can point me in the right direction it would be greatly appreciated.
Thanks in advance
Sark
Sub PowerClip()
Dim c As Shape, sh As Shape
Set c = ActiveSelection.Shapes.Item(1) 'Sets the the container, the last object selected
Set sh = ActiveSelection.Shapes.Item(2) 'Sets the powerclip object, the first object to be selected
sh.AddToPowerClip c
End Sub
(If ActiveSelection.Shapes.Count = 3 Then)
Sub PowerClip()Dim c As Shape, sh As ShapeIf ActiveSelection.Shapes.Count =3 Then Exit SubSet c = ActiveSelection.Shapes.Item(1) 'Sets the the container, the last object selectedSet sh = ActiveSelection.Shapes.Item(2) 'Sets the powerclip object, the first object to be selectedsh.AddToPowerClip cEnd Sub
Sub PowerClip2()Dim c As Shape, sh As ShapeIf ActiveSelection.Shapes.Count =3 Then GoTo here:Set c = ActiveSelection.Shapes.Item(1) 'Sets the the container, the last object selectedSet sh = ActiveSelection.Shapes.Item(2) 'Sets the powerclip object, the first object to be selectedsh.AddToPowerClip chere:End Sub
Mek...Thanks for the reply, it's appreciated. However, I think you've misunderstood me.
I know I need to add Exit Sub to end the macro. It was the issue of having two or three objects selected.
I've now figured I need to add > in front of equals as follows.
If ActiveSelection.Shapes.Count >= 2 Then
The code will now run if two or more objects are selected, if less than two it will exit.
I had tried the > tag but had assumed it went after equals, which seems logical,...but no?
Thanks again