Add gradient to shape / line
I am trying to add a gradient to a line shape in Excel using VBA. This feature is available in the section Line Color
under the option Format Shape
. Despite this feature existing under the option Format Shape
, I cannot reproduce the functionality in VBA. My code:
With ActiveSheet.Shapes("Straight Connector 4")
.Line.ForeColor.RGB = RGB(193, 193, 193)
.Line.Transparency = 0.25
.Line.Visible = msoTrue
.Line.ForeColor.SchemeColor = 24
.Line.BackColor.SchemeColor = 34
.Line.GradientStops.Insert RGB(255, 0, 0), 0.25 ' Creates error
.Line.Gradient.ColorStops.Add (1) ' Creates error
End With
I know you can easily add a gradient to a form fill, but all search results return nothing when you want to add a gradient to a form line. Any ideas are more than welcome.
+3
source to share
1 answer