从Range.Interior.Color(或任何其他颜色属性)返回RGB值 [英] Return RGB values from Range.Interior.Color (or any other Color Property)

查看:3418
本文介绍了从Range.Interior.Color(或任何其他颜色属性)返回RGB值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图逐渐改变单元格的背景颜色为黑色,我发现Range.Interior.Color方法返回一个看似任意的长。看看MSDN上的文档,几乎没有什么这个数字代表。有没有办法从这个long返回RGB值。

解决方案

简短答案:



没有内置的功能。



是从Interior.Color属性返回的典型十六进制数的十进制转换,我们习惯看到html中的颜色例如66FF66。此外,可以将常量xlNone(-4142)传递给设置单元格,使其在后台没有颜色,但是这样的单元格被标记为白色 RGB(255,255,255) Get 属性。知道这一点,我们可以写一个函数,返回一个或所有的适当的RGB值。



幸运的是,一个亲切的先生Allan Wyatt已经做到了这里! p>

确定颜色的RGB值


I was trying to incrementally change the background color of a cell to black, and I found that the Range.Interior.Color method returns a Long which is seemingly arbitrary. Looking at the documentation on MSDN, there is nearly nothing about what this number represents. Is there a way to return the RGB value from this long. I effectively need the opposite of the RGB(red, green, blue) function.

解决方案

Short Answer:

There is no built in functionality for this. You must write your own function.

Long Answer:

The long that is returned from the Interior.Color property is a decimal conversion of the typical hexidecimal numbers that we are used to seeing for colors in html e.g. "66FF66". Additionally the constant xlNone (-4142) can be passed to set cell to have no color in the background, however such cells are marked white RGB(255, 255, 255) from the Get property. Knowing this, we can write a function that returns one or all of the appropriate RGB values.

Luckily, a kind Mr. Allan Wyatt has done just that here!

Determining the RGB Value of a Color

这篇关于从Range.Interior.Color(或任何其他颜色属性)返回RGB值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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