在vb .net中,如何将System.Color(或)Color.FromArgb(….)强制转换为Microsoft.Office.Interop.Word.WdColor?
解决方法
见
the C# answer here.
您需要将其转换为十六进制样式RGB:
引用Cole Cameron对该答案的评论:
Sum the Red,Green,and Blue values of the named color,multiplying the Green & Blue values by hexadecimal modifiers so that the value is effectively 0xBBGGRR (base doesn’t really matter,an integer’s an integer),then cast that to the WdColor enumeration type.
示例(转换自Cole Cameron的C#示例):
Dim c As Color = Colors.Blue Dim wdc = DirectCast(c.R + &H100 * c.G + &H10000 * c.B,Microsoft.Office.Interop.Word.WdColor)