Change Fill Shape Color

Started by DJozef87, October 21, 2011, 08:47:07 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DJozef87

Hello guys,

I know that's a very stupid question but I try all the examples that I found and it didn't work
I want change the fill color of a selected shapes, I try to change the value of FillForegnd and FillBkgnd Cells but it didn't work !!


Dim shp As Visio.shape
For Each shp In ActiveWindow.Selection
'change the color
Next

DJozef87

It's a problem in my Stencil because when I try shp.Cells("Fillforegnd") = 2 with a shape from another Stencil It works !

Jumpy

Maybe you have a protection activated? Or Guard function in the cell?
Use shp.Cells("Fillforegnd").FormulaForce = 2 or sth. like that

DJozef87

The problem is that it works with shp.Cells("LineColor") but it not works with Fillforegnd and FillPattern cells and I really need to set values in these two cells... I tried with .FormulaForce and I tried with .Result but it doesn't work !

Jumpy

Quote from: DJozef87 on October 21, 2011, 12:09:48 PM
The problem is that it works with shp.Cells("LineColor") but it not works with Fillforegnd and FillPattern cells and I really need to set values in these two cells... I tried with .FormulaForce and I tried with .Result but it doesn't work !

Do you get an error or is it only, that nothin happens?
Have you looked in the shapesheet, if the cells have new values and they only don't get displayed?

Could you post your code and upload one of those shapes, so we can look in it's shapesheet and try to reproduce your problem?

DJozef87

the cells have new values  but nothin is displayed !! I don't know why... even If I close the document and open It the shapes have the new color values but nothin is displayed again :(

Jumpy

I would realy like to see a shape. Because:
- Maybe your shape is a group and if the group has no own geometry (only subshapes) you can't change a color.
- Or geometry noshow is true
- Or ShapeTransparency is 100%
- Or the combination of FillPattern, ForegrndColor, BackgrndColor doesn't work
- Or ...

DJozef87

#7
yes how can I get a Shape to upload it here ?  ;D

Jumpy

Empty drawing *.vsd with only the shape in it.

Then when replying to this post. Below the white Edit-Box click on "Attachments and other options"

DJozef87

This particular shape don't want to display the new value of linecolor and fillpattern cells but with FillForegnd cell it works !! and Thank you for your help

DJozef87

Hello Jumpy,

So you find the problem ?

Jumpy

Hello,

misted your post, where you uploaded the shape, sorry.
Will look into it this evening, when I have Visio available.

Jumpy

wapperdude

Hmmmm.  Downloaded your file and it seems to be OK at first. Tried a couple more times, and it broke. This is a grouped shape, and your search is only finding the top group level.  The fill and line colors are not pushing down into the sub-shape which actually has the visible characteristics.  Is this a custom built shape? 

Basically, the displayed shape is named AgentFirstLevel. Its line color and foregnd color cells must reference the same cells in the toplevel shape, that way the values pass down from the group to the sub-shape.  Put the guard() functions around the formulas in the sub-shape.

Personal preference would be to change your formula to use rgb function instead of the color index number, e.g., shp.Cells("FillForegnd").FormulaForce = "RGB(0, 255, 0)".

HTH
Wapperdude
Visio 2019 Pro

DJozef87

Hi wapperdude,

yes this is a custom built shape :)
I understood your explanation but I not the point around guard fontion ... if I use this fonction can I change the color without problems? and how I can use it!?

vojo

Hi...not to put a damper on this thread....but you guys realize you dont need VBA to do this, right

see below

right click the blade.....pick a category, say FC....watch the ports change color

The bottom has some other stuff about enabling/disabling connection points.....dont mind this stuff

Both shapes have  NO VBA at all.