RGB Example

K

K.Kazinski

Hi,

Does anyone have an example of setting the fill color and using RGB. I already have an enum with all the colors I want to use, but when I try to use them I only get black for a fill color.

I have tried:
vsoShape.CellsU("FillForegnd") = RGB(240, 0, 0) ' Red
and this produces a filled black shape.

Thanks,

Ken
 
J

John Marshall, MVP

That format takes an index rather than a colour value. There are some
examples of dealing with colour at
www.mvps.org/visio/VBA.htm.

Though there is an example of obtaining the RGB values, I do not think
there is an actual example of setting the colour to an RGB value.

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
K.Kazinski said:
Hi,

Does anyone have an example of setting the fill color and using RGB. I
already have an enum with all the colors I want to use, but when I try to
use them I only get black for a fill color.
 
K

K. Kazinski

Hi John

Actually I found the answer by using Visio 2003's record marco feature. The answer is
vsoShape.CellsU("FillForegnd").formulaU = "RGB(240, 0, 0) " by placing quotes around the formula I guess it is put in the cell

Ke
 
J

John Marshall, MVP

Thamks, I'll add this piece of information to the webpage.

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
K. Kazinski said:
Hi John,

Actually I found the answer by using Visio 2003's record marco feature. The answer is:
vsoShape.CellsU("FillForegnd").formulaU = "RGB(240, 0, 0) " by placing
quotes around the formula I guess it is put in the cell.
 
M

Mark Nelson [MS]

Without the quotes, you would be assigning the result of the VBA formula
RGB() to the cell. What you want is to assign a string containing the Visio
formula RGB() to the cell. Also, if you wanted to assign a literal string
(not a Visio formula) to a cell, you would need yet another set of quotes
(doubled up to tell VBA that you want a quote character in the string). For
example, to assign the characters ABC to a custom property cell, try
formulaU = """ABC""".

--
Mark Nelson
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.


K. Kazinski said:
Hi John,

Actually I found the answer by using Visio 2003's record marco feature. The answer is:
vsoShape.CellsU("FillForegnd").formulaU = "RGB(240, 0, 0) " by placing
quotes around the formula I guess it is put in the cell.
 
K

K. Kazinski

Hi Mark,

When I tried it without the quotes I kept getting errors, but I will try that again.

Ken
 
M

Mark Nelson [MS]

Actually, that was more a hypothetical example. I don't believe that VBA
has an RGB function.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top