Resetting Subshape name to Sheet.ID

Started by Miki, November 21, 2017, 05:15:39 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Miki

Hello,
I have a master with various subshapes. These subshapes were given unique names and are interlinked in shapesheets. When I go into the shapesheet of those subshapes, it show the name in the the formula instead of Sheet.ID, i.e. it will show "Track!PinX" instead of "Sheet12!PinX".

It kind of becomes difficult to follow the linkage due to this. Is there a way to reset these back to Sheet.ID?
I tried deleting the names in "Drawing Explorer" and it will give me the correct Sheet.ID, but it changes it back to name when I reopen the drawing.

I saw this post had a similar question, but I want to reset it back.
http://visguy.com/vgforum/index.php?topic=3369.msg13137#msg13137

Thanks
-Miki

Surrogate

If those subshapes have unique names, visio application engine automatically show names of subshapes!
It is reason why I don't use unique names for subshapes in master.

wapperdude

#2
The following code will reset a "named" shape back to its ID based name, i.e., sheet.xyz

The code will only work on one selected shape at a time, but could be modified to search thru all shapes on a page, all subshapes in a group, or even recursively for ALL shapes.  But, not knowing more details, here is the core.  Basically, you need to reset both the Name and NameU properties of the shape.  Fortunately, the ID is preserved.

No extensive testing was done, so there may be cases where this will yield undesired results.

HTH
Wapperdude


Sub UndoName()
    Dim vShp As Shape
    Dim shpName As String
   
    Set vShp = ActiveWindow.Selection(1)
             shpName = "Sheet." & vShp.ID

            If StrComp(shpName, vShp.Name, vbTextCompare) Or StrComp(shpName, vShp.NameU, vbTextCompare) Then
'                Debug.Print vShp.ID, "    "; vShp.Name, "    ", vShp.NameU
                vShp.Name = shpName
                vShp.NameU = shpName
'                Debug.Print vShp.ID, "    "; vShp.Name, "    ", vShp.NameU
            End If
End Sub
Visio 2019 Pro

wapperdude

A more complete solution is provided here with sample file.  Allows recursive searching thru all shapes on a page:  http://visguy.com/vgforum/index.php?topic=8160.0

Wapperdude
Visio 2019 Pro

Miki

Thank you so much. Your Recursive Shape Naming works perfectly.

- Miki