I have a visual basic macro that is supposed to set the Width cell to "guard(textwidth(thetext))" for all the selected shapes.
However, it fails on the first shape whose width cell is already guarded.
1. Is there a way to detect if the cell is guarded?
2. Is there a way to unguard a cell?
Thanks,
Chelmite
Public Sub Set_TextWidthHeight()
Dim vsoSelection As Visio.Selection
Dim intCounter As Integer
Dim item As Shape
Dim vsoCell As Visio.Cell
'Get the selected shapes and assign them to a Selection object.
Set vsoSelection = ActiveWindow.Selection
For intCounter = 1 To vsoSelection.Count
'Get the next open document.
Set item = vsoSelection.item(intCounter)
Set vsoCell = item.CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight)
vsoCell.Formula = "guard(textheight(thetext,width))"
Set vsoCell = item.CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth)
vsoCell.Formula = "guard(textwidth(thetext))"
Next intCounter
End Sub
Use .FormulaForce to override the guard().
How do I detect when a cell is guarded?
Either, put the statement in a try .. except handler (or whatever it is in VBA), or use .FormulaForce all the time.
Thanks!
Chelmite
If Instr(Upper(vsoCell.FormulaU),"GUARD")>0 then