Orthogod
Orthogod

Reputation: 143

Excel VBA remove gradient from shape

https://msdn.microsoft.com/en-us/vba/excel-vba/articles/shape-fill-property-excel

 Set myDocument = Worksheets(1) 
    With myDocument.Shapes.AddShape(msoShapeRectangle, 90, 90, 90, 50).Fill 
        .ForeColor.RGB = RGB(128, 0, 0) 
        .BackColor.RGB = RGB(170, 170, 170) 
        .TwoColorGradient msoGradientHorizontal, 1 
    End With

How to remove the gradient once it has been added to a shape in Excel?

Upvotes: 2

Views: 1072

Answers (1)

Chronocidal
Chronocidal

Reputation: 8081

The FillFormat.Solid method will remove any Gradient or Pattern.

The new colour will be the colour at Gradient position 0.

For example, this will remove the gradient from the second shape in the first worksheet:

ThisWorkbook.Worksheets(1).Shapes(2).Fill.Solid

Upvotes: 3

Related Questions