Number shapes in relation to their order of selection

Started by hill041, October 15, 2019, 03:26:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hill041

Hi everyone!

I'm trying to write some code to do a similar thing to the 'Number Shapes' Add On. I need it to add a property called Prop.PositionNumber to each shape and increment this number relative to the order in which each shape has been selected.

Has anyone got any ideas on how i can do this?

Thanks in advance,

Daniel.

Obsidian

Hello. May be something like this:



Public Sub SetShapesCount()
Dim shp As Visio.Shape
Dim i As Integer
    i = 1
    For Each shp In Application.ActiveWindow.Selection
        SetCellVal shp, i
        i = i + 1
    Next shp
End Sub


Private Sub SetCellVal(ByRef shp As Visio.Shape, Optional ByVal defVal As Integer = 0)
    If Not shp.CellExists("Prop.PositionNumber", 0) Then
        shp.AddNamedRow visSectionProp, "PositionNumber", visTagDefault
    End If
   
    shp.Cells("Prop.PositionNumber").Formula = defVal
End Sub
And may be from the darkness something beautiful will rize

hill041

Thanks Obsidian,

I didnt realise visio noted the order in which things were selected so this is a big help. quite simple really.

dan.