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
Please use triple quotation marks !
shapeType = """Transition"""
Thank you!
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.