Index shape data

Started by whwaldrep, June 23, 2009, 06:36:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

whwaldrep

Hello all, I have a Shape that has a "Shape Data" called Step.  I want this to index +1 from the one above each time.  I need this for flowcharts I am creating and sometimes I need to add a step and I have to go thru and renumber all of them.  If there is not one above I want it to be manually entered.  So I guess my big question it how to obtain the shape's data that is above the current one.

Thank you for your help.

Paul Herber

Not going to be at all easy, you are going to need some code to do that and even that won't be easy.
The shape's index number is determined by the order in which shapes were dropped on the page and there is no ordering within Visio for a shape's physical position on a page.
Electronic and Electrical engineering, business and software stencils for Visio -

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

whwaldrep

Ok thanks, I will just use this for now.

I just will need to add this to the right click context.  Any suggestions would be appreciated.


Sub Index()
    Dim xy As Visio.Selection
    Dim xyz As Integer
    Set xy = Visio.ActiveWindow.Selection
    xyz = 0
    Dim x As Visio.Shape
    For Each x In xy
        x.Cells("User.Step").FormulaForceU = Chr(34) & xyz & Chr(34)
        xyz = xyz + 1
    Next x
End Sub

whwaldrep

#3
Ok so I was trying to create a right click menu for the shape, in the shape file I created the macro called Public Sub IndexSub().  In the action of the shape I put =Runaddon("ThisDocument.IndexSub")

But it does nothing...  Any Help?


*Edit:  Thank you all for your help.  I did firgure this out with =RUNMACRO(Module.Proc)

Paul Herber

Well, that code isn't going to do what you asked for, but it will set User.Step in the shapes but in the order in which the shapes were put on the page.
You could do something like:
1. clear the User.Step for each shape.
2. Create a data structure array (index: integer; Y: float)
3. for each shape get the shape.Index and shape.PinY and put the numbers into the array.
4. sort the array on the Y
5. set the User.Step in the order of the indexes in the sorted array.

Electronic and Electrical engineering, business and software stencils for Visio -

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

whwaldrep

No you are exactly right, I kind of settled on this.  As I could not figure another way of doing it easily.