Author Topic: Resetting Subshape name to Sheet.ID  (Read 342 times)

0 Members and 1 Guest are viewing this topic.

Miki

  • Jr. Member
  • **
  • Posts: 56
Resetting Subshape name to Sheet.ID
« on: November 21, 2017, 12: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

Surrogate

  • Hero Member
  • *****
  • Posts: 737
Re: Resetting Subshape name to Sheet.ID
« Reply #1 on: November 21, 2017, 11:20:52 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2985
  • Ideas Visio-lized into solutions
Re: Resetting Subshape name to Sheet.ID
« Reply #2 on: November 22, 2017, 05: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

Code: [Select]
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
« Last Edit: November 22, 2017, 05:51:50 PM by wapperdude »
Visio 2007 Std

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2985
  • Ideas Visio-lized into solutions
Re: Resetting Subshape name to Sheet.ID
« Reply #3 on: November 23, 2017, 03: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

Wapperdude
Visio 2007 Std

Miki

  • Jr. Member
  • **
  • Posts: 56
Re: Resetting Subshape name to Sheet.ID
« Reply #4 on: December 06, 2017, 02:06:46 PM »
Thank you so much. Your Recursive Shape Naming works perfectly.

- Miki