Hi Cindy,
Thanks for giving this answer! It helped me solve my problem (I was coding in C# and needed an RGB color), and could do it easily using your solution.
Cindy M. wrote:
Re: How to set Word colors in c#?
18-Jun-08
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 Snippe
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 Meiste
INTER-Solutions, Switzerlan
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005
http://www.word.mvps.or
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail
Previous Posts In This Thread:
How to set Word colors in c#?
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???
Thank you.
RE: How to set Word colors in c#?
In VBA, you can use
Selection.Range.Font.Color = RGB(10, 60, 165)
RE: How to set Word colors in c#?
Is there any way to do it in C#?
RE: How to set Word colors in c#?
I believe RGB is a VB function
I do not know if there is an equivalent in C#
This is a VBA group after all..
Try in
microsoft.public.dotnet.languages.csharp
The 2007 Theme Colors are not RGB values.
The 2007 Theme Colors are not RGB values. The whole thing is described here:
http://www.wordarticles.com/Articles/Colours/2007.htm (well, maybe not the
whole thing yet, but it should be enough) - it gives VBA code but you can
use the same hex values in any language
--
Enjoy
Ton
Re: How to set Word colors in c#?
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 Snippe
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 Meiste
INTER-Solutions, Switzerlan
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005
http://www.word.mvps.or
This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail
Re: How to set Word colors in c#?
Ha! I just noticed the "2007" in the poster alias..
I had just focused on the subject line..
I don't have 2007 on my machine at work and I am not all that good with
C#... Should've stayed away!
Thanks for jumping in!
Submitted via EggHeadCafe - Software Developer Portal of Choice
ASP.NET Multi-Lingual Language Translations
http://www.eggheadcafe.com/tutorial...d56-766a992561ef/aspnet-multilingual-lan.aspx