Author Topic: Rename all shapes  (Read 137 times)

0 Members and 1 Guest are viewing this topic.

lizat

  • Jr. Member
  • **
  • Posts: 12
Rename all shapes
« on: June 26, 2020, 01: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:
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

  • Hero Member
  • *****
  • Posts: 959
    • ShapeSheet™ Knowledge Base
Re: Rename all shapes
« Reply #1 on: June 26, 2020, 03:42:46 PM »
You can not have more than single shape with name like 'not yet' on page!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3785
  • Ideas Visio-lized into solutions
Re: Rename all shapes
« Reply #2 on: June 27, 2020, 12: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.
Visio 2019 Pro

lizat

  • Jr. Member
  • **
  • Posts: 12
Re: Rename all shapes
« Reply #3 on: June 30, 2020, 08:25:10 AM »
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

  • Hero Member
  • *****
  • Posts: 2693
Re: Rename all shapes
« Reply #4 on: June 30, 2020, 02:05:34 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

  • Hero Member
  • *****
  • Posts: 1456
Re: Rename all shapes
« Reply #5 on: June 30, 2020, 07:52:07 PM »
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.