[quote user="Barry Lothian"] I'm not sure how to deal with a colour of 127,127,127[/quote]
When R, G and B have equal values you're looking at a lifeless colour anywhere between white, 50 or more shades of grey, to black.
[quote user="Barry Lothian"] I would prefer to keep the value in the grayscale range as opposed to true inverse colour[/quote]
I have no idea what a 'true inverse colour' might be. Is dark grey the inverse of light grey? Is primrose yellow the inverse of violet? RGB is not the only way of representing colour: Hue, Lightness and Saturation (HLS) is another. In the case of RGB=127,127,127 the opposite might be white (255, 255, 255) or black (0, 0, 0).
[quote user="Barry Lothian"]is there an MDL function that can calculate it[/quote]
That's a red herring. Neither MDL nor VBA have much to do with the colours used in Microsoft dialog boxes.
Since colour perception is a human condition, a lot of work over how we perceive colours has been done in recent centuries. Search the web for something like colour contrast to see some examples.