Visio Guy

Visio Discussions => ShapeSheet & Smart Shapes => Topic started by: Miki on November 21, 2017, 05:15:39 PM

Title: Resetting Subshape name to Sheet.ID
Post by: Miki on November 21, 2017, 05:15:39 PM
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
Title: Re: Resetting Subshape name to Sheet.ID
Post by: Surrogate on November 22, 2017, 04:20:52 AM
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.
Title: Re: Resetting Subshape name to Sheet.ID
Post by: wapperdude on November 22, 2017, 10:21:25 PM
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
Title: Re: Resetting Subshape name to Sheet.ID
Post by: wapperdude on November 23, 2017, 08:03:19 PM
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 (http://visguy.com/vgforum/index.php?topic=8160.0)

Wapperdude
Title: Re: Resetting Subshape name to Sheet.ID
Post by: Miki on December 06, 2017, 07:06:46 PM
Thank you so much. Your Recursive Shape Naming works perfectly.

- Miki