转换System.Color到Microsoft Word WdColor [英] Convert System.Color To Microsoft Word WdColor

查看:239
本文介绍了转换System.Color到Microsoft Word WdColor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是相当新的C#,发现它几乎无法形容的,有没有为RGB颜色或system.color转换为WdColor一个简单的方法!



VB简单,C# - ?是不是真的是很难做到的。



我不想引用VB在我的项目



我在某些字自动化项目使用这种着色的字体,例如:

  tmpRange.Find.Replacement.Font.Color = Color.FromArgb(100,150,75); 



但是,这上面的行是不可能的,它需要一个WdColor


解决方案

 颜色C = Colors.Blue; 
VAR WDC =(Microsoft.Office.Interop.Word.WdColor)(C.R + 0x100的* C,G + 0x10000的* C.B);


I'm rather new to C# and find it almost unspeakable that there isn't a simple way for converting an RGB color or system.color to a WdColor!

VB is simple, C# - is it really that hard to do?

I do not want to reference VB in my project.

I'm using this in some word automation project to color a font, e.g.

tmpRange.Find.Replacement.Font.Color = Color.FromArgb(100, 150, 75); 

But this above line isn't possible, it needs to be a WdColor.

解决方案

Color c = Colors.Blue;
var wdc = (Microsoft.Office.Interop.Word.WdColor)(c.R + 0x100 * c.G + 0x10000 * c.B);

这篇关于转换System.Color到Microsoft Word WdColor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆