Reputation: 221
I want when I have a shape (here circles) selectionned and click a button trigger a color change of shape selectionned.
For example if I click on red button, the shape background color change to red.
In the below code I try to change background color to red for the shape selectionned but I have error message: a property or method not managed by this object
Sub fillColorRed()
With Selection
.ForeColor.RGB = RGB(255, 0, 0)
End With
End Sub
How can fix it ? Also I often get this error, I don't understand how to avoid this type of error. Thank for your help.
Upvotes: 0
Views: 867
Reputation: 3230
The below code works for me. It detects the selected shape. Beware, you must select a shape else you will have an error.
With Selection.ShapeRange.Fill
.Visible = msoTrue
.ForeColor.RGB = RGB(106, 208, 152)
.Transparency = 0
.Solid
End With
Upvotes: 2