Visio Guy

Visio Discussions => Programming & Code => Topic started by: lizat on June 26, 2020, 06:21:05 PM

Title: Rename all shapes
Post by: lizat on June 26, 2020, 06:21:05 PM
I want to rename my shapes to a standard name which I will then update as I add hyperlinks. I have this code:

Sub SetNameToNotLinkedYet()
'Macro to rename all shapes
    Dim vShp As Shape
    Dim vPg As Page
   
    For Each vPg In ActiveDocument.Pages
        For Each vShp In vPg.Shapes
            On Error Resume Next
                vShp.Name = "Not linked yet"
                vShp.NameU = "Not linked yet"
        Next
    Next
   
End Sub


However some of my shaps are 'groups' of shapes and it doesn't seem to do the members of the group. How can I do this?

Thank you
Title: Re: Rename all shapes
Post by: Surrogate on June 26, 2020, 08:42:46 PM
You can not have more than single shape with name like 'not yet' on page!
Title: Re: Rename all shapes
Post by: wapperdude on June 27, 2020, 05:12:30 AM
...but, you could add an entry into the shapesheet to basically do the same.  For example, create a User Section entry, with row name = User.Linked.  It's value could be Boolean, i.e., true or false.  Then I stead of searching for shapes with a name, search shape for cell User.Linked, and check its value.
Title: Re: Rename all shapes
Post by: lizat on June 30, 2020, 01:25:10 PM
Thank you Surrogate. In fact what seems to happen is the numeric id is appended so I have many 'Not linked yet.n' titles. I didn't code that but it seems to work.

In fact I would rather not have any alt text where I have no hyperlinks and have now found that I can remove all the <title>*</title> with apparently no ill effects So i am now doing this... unless anyone tells me of a drawback

Thank you
Title: Re: Rename all shapes
Post by: Yacine on June 30, 2020, 07:05:34 PM
Quote from: lizat on June 30, 2020, 01:25:10 PM
... unless anyone tells me of a drawback

You won't get the expected control over your system.

For example, if you copy an already named shape to a page where the shape name exists already, the shape will be renamed.

Follow Wapperdude's advice, it's the "right" way.
Title: Re: Rename all shapes
Post by: vojo on July 01, 2020, 12:52:07 AM
ID could be
your shape name || <random number or number of the sheet.xyz via parsing in a user cell or perhaps a timestamp of some sort>
That would make the ID file unique.