Can someone help me with following action? I want to loop 100 pictures in excel sheet and set them to Blur with a specific Radius value.
ActiveSheet.Shapes("Picture 412").Fill.PictureEffects.Insert msoEffectBlur
This statement is working but I don't know how to add a radius value. Also not sure how to loop through all the pictures.
CodePudding user response:
I upvoted the answer of antca230 because it shows how to set the radius. However, the rest of the code will not work, there are some issues:
(a) It loops over all shapes of the Activesheet using the variable picture
, however within the loop it uses another variable, and that will work always on the first shape.
(b) It will apply the effect to all shapes, but that will cause issues if you have other shapes (like a simple box) on the sheet. You should check the type of the shape before applying the effect
Dim picture As Shape
For Each picture In ActiveSheet.Shapes
If picture.Type = msoPicture Then
picture.Fill.PictureEffects.Insert msoEffectBlur
picture.Fill.PictureEffects(1).EffectParameters(1).Value = 4
End If
Next picture
CodePudding user response:
Maybe something like this? Been a long time since I used VBA
Dim picture As Shape
For Each picture In ActiveSheet.Shapes
Dim opic As Shape
Set opic = ActiveWindow.Selection.ShapeRange(1)
opic.Fill.PictureEffects.Insert (msoEffectBlur)
opic.Fill.PictureEffects(1).EffectParameters(1).Value = 20
Next picture
CodePudding user response:
Thx! The value parameter works great.
I removed the "picture.Type" if-statement as it type didn't match but without this it worked perfectly!
I come here often for hints, and since today asked first question with great support! Thanks all!