detect & unguard a shapesheet cell?

Started by chelmite, November 20, 2012, 11:45:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

chelmite

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

Paul Herber

Use .FormulaForce to override the guard().
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

chelmite

How do I detect when a cell is guarded?

Paul Herber

Either, put the statement in a try .. except handler (or whatever it is in VBA), or use .FormulaForce all the time.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/


Jumpy


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