How I get color stops on a gradient Shape? VBA

时间:2017-06-15 10:06:18

标签: excel vba excel-vba

How I get color stops on a shape? I'm creating a tree flow chart, and I want to give them a gradient and I also want to change the gradient by percentage, so I want that one node is with 50% for the both color stops.

So the code that I have until now for the give a gradient pattern is:

        QNode.Shapes(1).Fill.TwoColorGradient msoGradientVertical, 1

I was trying something like:

QNode.Shapes(1).Fill.Interior.Gradient.ColorStops.Add(0.66)

Not working...

Specification: Should work on 2003

1 个答案:

答案 0 :(得分:0)

I found the solution:

        With QNode.Shapes(1).Fill
            .ForeColor.RGB = RGB(255, 255, 255)
            .TwoColorGradient msoGradientVertical, 1
            .GradientStops(2).Color = RGB(0, 0, 0)
            .GradientStops(2).Position = 0.66               
        End With

I just have to use GradietStops =D with the position that I want, in that case, I just want two positions, so gradientStops(1) and gradientStops(2), but you also can add more positions.

      .GradientStops.Insert RGB(0, 0, 0), 0.66