Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: chelmite on November 20, 2012, 11:45:54 PM

Title: detect & unguard a shapesheet cell?
Post by: chelmite on November 20, 2012, 11:45:54 PM
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
Title: Re: detect & unguard a shapesheet cell?
Post by: Paul Herber on November 20, 2012, 11:48:11 PM
Use .FormulaForce to override the guard().
Title: Re: detect & unguard a shapesheet cell?
Post by: chelmite on November 21, 2012, 12:06:48 AM
How do I detect when a cell is guarded?
Title: Re: detect & unguard a shapesheet cell?
Post by: Paul Herber on November 21, 2012, 12:19:00 AM
Either, put the statement in a try .. except handler (or whatever it is in VBA), or use .FormulaForce all the time.
Title: Re: detect & unguard a shapesheet cell?
Post by: chelmite on November 21, 2012, 12:47:40 AM
Thanks!

Chelmite
Title: Re: detect & unguard a shapesheet cell?
Post by: Jumpy on November 21, 2012, 07:42:42 AM

If Instr(Upper(vsoCell.FormulaU),"GUARD")>0 then