
The first 3 shapes use Pattern fill, while the last uses Gradient fill. This means that, given an index, you can look up the color instance in the Colors collection.įollowing is some code to demo how to access the various types of coloring. Any additional custom colors used are added to the collection and are also given an index. Some built-in colors can be accessed by index: 0 = black, 1 = white, 2 = red, 3 = green etc all the way up to 23.

In the background, Visio maintains a Document.Colors collection. For other pattern types you're dealing with both FillForegnd and FillBkgnd.įor Gradient fill the FillGradientEnabled cell is set to 1 and this results in the Fill Gradient Stops section taking precedents.

Most shapes start off with a solid fill ( FillPattern 1) and this means that only the FillForegnd is used. The latter is from 2013 onwards.įor Pattern fill, you're looking at three cells: FillForegnd, FillBkgnd and FillPattern. Visio has two main methods of setting the fill color - Pattern fill and Gradient fill.

Once you've got a reference to the right shape then you can look at the respective cells. Getting hold of the fill color is not impacted by whether the shape is part of a group or not.
