Author Topic: Foreground fill color NOT respecting specified RGB  (Read 7588 times)

0 Members and 1 Guest are viewing this topic.

xgrove

  • Newbie
  • *
  • Posts: 6
Foreground fill color NOT respecting specified RGB
« on: January 21, 2015, 11:51:32 AM »
I've created a table of contents module that alternates the colors of the "buttons". Unfortunately the resulting colors are waaaay off. For instance RGB(224, 230, 205) becomes RGB(255,60,60). I see that when I right click on  a "button" and go to "Show ShapeSheet". I can manually change the value there and it works.

            ' Alternate the foreground color
            If (loopCount Mod 2 = 0) Then
                TOCEntry.Cells("FillForegnd") = RGB(195, 215, 232)
            Else
                TOCEntry.Cells("FillForegnd") = RGB(224, 230, 205)
            End If

Thanks.

Yacine

  • Hero Member
  • *****
  • Posts: 3153
Re: Foreground fill color NOT respecting specified RGB
« Reply #1 on: January 21, 2015, 12:48:09 PM »
1)
I see that the patterns repeat after 4 rows. Aren't there 4 possibilities?
--> select case loopcount Mod 4
case 0:
case 1:
case 2:
case 3:
end select

2) Is there any "error resume next" hiding that a shape's colour is protected?

3) Are you sure about the order of the shapes.
Try modifying an additional property, to check that the right shape is modified.
« Last Edit: January 21, 2015, 01:37:00 PM by Yacine »
Yacine

xgrove

  • Newbie
  • *
  • Posts: 6
Re: Foreground fill color NOT respecting specified RGB
« Reply #2 on: January 21, 2015, 01:12:31 PM »
Hi Yacine.

The image I attached was a mashup to show the colors that ARE displayed and the ones that SHOULD have been displayed. The process to generate the clickable "button" works fine; it's the passed in color value that is messed up.

I'll attach a snap of the result.

Richard

Yacine

  • Hero Member
  • *****
  • Posts: 3153
Re: Foreground fill color NOT respecting specified RGB
« Reply #3 on: January 21, 2015, 01:40:00 PM »
Next hypothesis:
Are the shapes groups?
When you modify a property of the group by code, the modification does not propagate to its children.
Yacine

xgrove

  • Newbie
  • *
  • Posts: 6
Re: Foreground fill color NOT respecting specified RGB
« Reply #4 on: January 21, 2015, 01:50:02 PM »
< Are the shapes groups? >
I cannot categorically say that they are NOT a group as they appear to be independent shapes.

Set TOCEntry = ActiveDocument.Pages(1).DrawRectangle(4.6, PosY, 4, PosY + 0.5)

Sidebar question: Since setting the color via RGB seems not to work, how can I specify a user defined color? As I was fooling around with this I noticed that I could assign each shape a number (highlighted below).

Question: Is there a table of these colors?

            If (loopCount Mod 2 = 0) Then
                TOCEntry.Cells("FillForegnd") = RGB(195, 215, 232)
                ' TOCEntry.Cells("FillForegnd") = 169
            Else
                TOCEntry.Cells("FillForegnd") = RGB(224, 230, 205)
                ' TOCEntry.Cells("FillForegnd") = 4
            End If

Yacine

  • Hero Member
  • *****
  • Posts: 3153
Re: Foreground fill color NOT respecting specified RGB
« Reply #5 on: January 21, 2015, 02:03:53 PM »
Quote
Are the shapes groups?I cannot categorically say that they are NOT a group as they appear to be independent shapes.

View/Drawing Explorer Window allows you to display the drawing explorer.
It will show you a tree view of the document, with pages, shapes, etc.
If a shape displays a "+" in front of it, it is a group.
In this case the code needs to iterate through the sub-shapes.
Something like:
for each subShape in shp.Shapes
  set color
next subShape


Colours table:
Not sure about this, but I think to recall that shape coloúr (integer) values are document dependent. Thus no list possible, but Google is your friend. ;)
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4744
  • Ideas Visio-lized into solutions
Re: Foreground fill color NOT respecting specified RGB
« Reply #6 on: January 21, 2015, 03:18:41 PM »
Change your syntax
  from: TOCEntry.Cells("FillForegnd") = RGB(195, 215, 232)
  to:  TOCEntry.Cells("FillForegnd").FormulaU = "RGB(195, 215, 232)"

Should work.

Wapperdude
Visio 2019 Pro

Yacine

  • Hero Member
  • *****
  • Posts: 3153
Re: Foreground fill color NOT respecting specified RGB
« Reply #7 on: January 21, 2015, 03:35:56 PM »
How embarrassing! Of Course!
Yacine

xgrove

  • Newbie
  • *
  • Posts: 6
Re: Foreground fill color NOT respecting specified RGB
« Reply #8 on: January 21, 2015, 03:42:18 PM »
wapperdude ... you're the DUDE!

Thank you. I will abide today.

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4744
  • Ideas Visio-lized into solutions
Re: Foreground fill color NOT respecting specified RGB
« Reply #9 on: January 21, 2015, 03:52:55 PM »
Just a 2nd pair of eyes.   Was still expecting a problem associated with group shapes per Yacine.  Sometimes being lucky works!   ;D
Visio 2019 Pro