WdColorIndex
is an enumeration, not an object that defines a color system. This means that the value you can assign is limited by the enumeration elements, e.g. wdBlack
or wdBlue
and their underlying integer values.
The technique you are using is to be applied to a WdColor
object instead of a WdColorIndex
enumeration:
var wordColor = (Microsoft.Office.Interop.Word.WdColor)(bgcolor.R + 0x100 * bgcolor.G + 0x10000 * bgcolor.B);
Highlighting in a Word document is limited to a number of colors, as defined in the WdColorIndex
enumeration. Therefore, you cannot simply convert any color to a Word color for highlighting. You have to pick one of the available values. See MSDN for WdColorIndex for possible values.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…