The first shows how to select all the faces in a part one at a time, the second shows how to change the color. Now all you need is a means of getting the color, and that may be as easy to retrieve as it is to set. I'm not a programmer, but maybe one of them will be by with a better method, but I've given you a start.
A quick search turned up these two articles from the help to get you started:
2016 SOLIDWORKS API Help - Select All Faces on Part Example (VBA)
2018 SOLIDWORKS API Help - Change Color of Face Example (VBA)
The first shows how to select all the faces in a part one at a time, the second shows how to change the color. Now all you need is a means of getting the color, and that may be as easy to retrieve as it is to set. I'm not a programmer, but maybe one of them will be by with a better method, but I've given you a start.