Cindy
Wed Jun 18 06:18:03 PDT 2008
> How to set Word color in c#? The only colors that I am able to set in Word
> are in enumeration WdColor.
> Word.WdColor color = Word.WdColor.wdColorTurquoise;
>
> How can I set in c# shadings that are not in enumeration, for example
> â??Blue, Accent 1â???
>
I copied the following from the VSTO forum some time ago:
"You can't directly convert a System.Drawing.Color value to its WdColor
equivalent. The Font.Color property can be set to a WdColor value or the
result of the VB RGB function. The Microsoft.VisualBasic.Information.RGB()
method duplicates this function. So you can do the following:
Code Snippet
rng.Font.Color = (Microsoft.Office.Interop.Word.WdColor)
Microsoft.VisualBasic.Information.RGB(0, 112, 192);
Note that this requires you reference the Microsoft.VisualBasic assembly from
your project.
You can also use the System.Drawing.ColorTranslator.ToOle() method. This
doesn't require the reference to the Microsoft.VisualBasic assembly."
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)