Rename all shapes

Started by lizat, June 26, 2020, 06:21:05 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

lizat

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

Surrogate

You can not have more than single shape with name like 'not yet' on page!

wapperdude

...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.
Visio 2019 Pro

lizat

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

Yacine

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.
Yacine

vojo

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.