Problem trying to add user-defined section and row to user section

Started by spersels, March 13, 2019, 03:12:22 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

spersels

Following code run fine up to the last line where I try to set the value of the cell.

Section gets created and a row with the tag User.ShapeType is created.   But I don't know how to update the value of the cell.

The last line of code pops a #NAME? error.


Public Sub fixmaster()
        Dim vsoShapes As shapes
    Dim vsoShape As Shape
    Dim FSMMaster As Master
    Dim myCell As Cell
    Dim shapeType As String
   
    Set vsoShapes = ActivePage.shapes
   
    For Each vsoShape In vsoShapes
        If Left(vsoShape.Name, 3) = "Tra" Then
            shapeType = "=Transition"
        End If
       
        If Left(vsoShape.Name, 3) = "FSM" Then
            shapeType = "=State"
        End If
       
        vsoShape.AddSection (visSectionUser)
        vsoShape.AddNamedRow visSectionUser, "ShapeType", visTagDefault
        Set myCell = vsoShape.Cells("User.ShapeType.Value")
        myCell.Formula = shapeType
    Next vsoShape
End Sub

Surrogate

Please use triple quotation marks !
shapeType = """Transition"""


Paul Herber

Your code is looping round all the shapes setting ShapeType, but if the shape is not a Transition or a State then the myCell.Formula is set to the last used value. So, set shapeType = "" before testing the shape types.
Also, you should use myCell.Value, not myCell.Formula.
Electronic and Electrical engineering, business and software stencils for Visio -

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