oompa_l was wondering how to set the Height formula for a bunch of shapes over in this thread: http://visguy.com/vgforum/index.php?topic=47.0
I'll talk about two ways of going about this right now.
Are the shapes all instances of the same master?
If so, then do this:
1. File > Shapes > Show Document Stencil to see the local stencil, which contains masters used in the document
2. Double-click the master icon
3. Edit the formula
This will change the formula in all the instances in all of the pages in the document -- unless -- you've already overridden formulas in individual shapes.
Write a macro
Like Cyndi Lauper sang, Coders just want to have fun. We can always get more done, more quickly (and cause more trouble) with VBA. So let's have at it:
'// Get a bunch of selected shapes
Dim sel as Visio.Selection
Set sel = Visio.ActiveWindow.Selection
'// 'Do' each shape in the selection:
Dim shp as Visio.Shape
For Each shp in sel
'// Note: here are several examples that you can
'// comment-out and uncomment
'// Set the value in inches:
shp.Cells("Width").ResultIU = 2.0
'//...or set the value in centimeters:
'shp.Cells("Width").Result(Visio.visUnitCodes.visCentimeters) = 50.8
'//...or set the formula
'shp.Cells("Width").Formula = "GUARD(Prop.Row_1)"
'//...or override a cell that already has a GUARDed formula:
'shp.Cells("Width").FormulaForce = "GUARD(Prop.Row_1)"
'// You can get at cells with indices as well:
'shp.CellsSRC(Visio.VisSectionIndices.visSectionObject, _
' Visio.VisRowIndices.visRowXFormOut, _
' Visio.VisCellIndices.visXFormWidth).Result = 3.0
'// Put the cursor in a ShapeSheet cell, then hit F1 to get the
'// Section, Row, Column indices for a cell.
Next shp
where can i go for explanation on implementing macros?
I prefer option 1, but I am still having trouble understanding masters...I would assume tha a change in a master would affect all instances but I have found this not to be the case. Also, when I tried to make a shape from scratch and place in the master a formula that included a formula, in this case "=Prop._VisDM_length_in/50" I was told there was an error in the formula. My guess s that it's because there is no shapesheet data and so it doesnt know what I am referring to. It seems to be a chicken-egg scenario. My is Visio finicky, or what!
i tried to find my way intuitively to making that macro but I got an error:
"Compiler Error
Invalid Outside Procedure"
The whole bunch of code needs to be wrapped in a sub, ie:
Sub DoStuff
...
...
End Sub
woh! it worked...
and...when you have a moment, I am still unsure how to build the formula into the master shape - I was getting an error before. see above.