从Range.Interior.Color(或任何其他颜色属性)返回RGB值 [英] Return RGB values from Range.Interior.Color (or any other Color Property)
问题描述
我试图逐渐将单元格的背景颜色更改为黑色,我发现Range.Interior.Color方法返回一个Long,看起来是任意的。看看MSDN上的文档,几乎没有什么这个数字代表。有没有办法从这个很长的时间返回RGB值。我有效地需要与RGB(红色,绿色和蓝色)功能相反。
strong>
没有内置的功能。你必须写你自己的功能。
长答案
从Interior.Color属性返回一个十进制转换的典型十六进制数,我们用于查看HTML中的颜色,例如66FF66。另外,常数xlNone(-4142)可以传递给设置单元格在背景中没有颜色,但是这样的单元格标记为白色 RGB(255,255,255)
获取
属性。知道这一点,我们可以编写一个返回一个或所有相应RGB值的函数。
幸运的是,Allan Wyatt先生在这里完成了这个! p>
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屋!