Why don't shapesheet changes update the shape?

T

TonyB

I'm using the following code to change the foreground colour of a shape:

myshape.CellsU("FillForegnd").FormulaForceU = "=RGB(0,255,0)"

I've tried combinations of Result, Formula, FormulaForce... everthing I can
think of. I can get the Shapesheet cell value to reflect "=RGB(0,255,0)" but
its still ****ing red!

Also, if I manually right-click->Fill I can see that Visio thinks the shape
is green, and clicking apply will turn it green, but it just won't work from
VBA. I've also tried using:
myshape.CellsU("FillForegnd").trigger

... although I'm not entirely sure if that's supposed to have any effect.

I'm using Visio2002 (not my choice, but my client's).

Help!
 
C

Chris Roth [Visio MVP]

Hi TonyB,

You're probably referencing a shape that is a group.

In the UI, when a user selects a group, then clicks a fill color, all of
the sub-shapes get that color too (unless protected, guarded, etc.)

Via code, though, it doesn't work that way. You'll need to go into your
sub-shapes - something like this:

'...shp is the top-level shape:
For Each shpSub as Visio.Shape in shp.Shapes
shpSub.Cells("FillForegnd").FormulaForceU = "RGB(255,0,0)"
Next shpSub

This code might also need to be recursive, depending on how much
grouping you've done: --> shpSub.Shapes.Item()

--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People

Articles: http://www.visguy.com
Shapes: http://www.visguy.com/shapes
Dev: http://www.visguy.com/category/development/
Forum: http://www.viguy.com/vgforum
 
T

TonyB

Chris, John... many thanks... its a group of shapes.

The shape in question is a milestone from the standard visio template,
didn't think about it being a group not a single shape.

Problem solved.
Cheers,
T
 

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