currently I figured out how to add multiple gradient stops with the code below. However, this way, I have to put RGB number in the code.
What I wanted to do is to get the color from another shape and put that color into the gradient stops instead of putting the RGB number.
I tried these lines but they don't work, any idea how to make it work? Thank you!
Function Get_Color(Index As Long) As Long
Get_Color = ActiveSheet.Shapes.Range(Array("Fill")).Fill.ForeColor
End Function
Sub gradients()
Dim Point_Index As Long
ActiveSheet.Shapes("Sauqre1").Select
With ActiveSheet.Shapes("Sauqre1").Fill
.ForeColor.RGB = RGB(0, 128, 128)
.OneColorGradient msoGradientHorizontal, 1, 1
.GradientStops.Insert RGB(255, 0, 0), 0.25 *This way work ok
*But I want to get color from another shape, I tried these 3 lines, none of them work so far.
.GradientStops.Insert RGB = Get_Color(Point_Index)
.GradientStops.Insert.RGB = Get_Color(Point_Index)
.GradientStops.Insert.Color.RGB = Get_Color(Point_Index)
End With
End Sub
question from:
https://stackoverflow.com/questions/65921389/vba-getting-multiple-gradient-color-from-another-shape-color 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…