In Backward Order:
Modul1 is the Name of the VBA Modul where you copied the code. In the VBA-Editor you can have many moduls where you can store VBA-code. The moduls belong to the drawing and a saved with it. Every drawing has a modul called "ThisDocument" that is the standard modul. You can (and probably have) add(ed) a new modul. Moduls added get name like Modul1, Modul2,... The names can be changend later.
NB: In Extras-Macros you can assign Short-Cuts to the macros to make it more easy to start them.
-----------
Now it gets complicated: The names in Visio!A shape has
a Name,
a NameU (U = Universal Name)
a NameID (Sheet.123 -> The word Sheet, followed by "." followed by the ID-number)
an ID (The ID number like 123)
an Indexnumber (Different from the ID, its the number of the Shape in the Shapes-Collection of the page, the Shape is on).
If you take a simple shape from a stencil, say the Box-Shape (Rectangle), and drag it on the page it gets:
Name: Box
NameU: Box
NameID: Sheet.5 (number is only an example)
ID: 5
Now you drag another Box-shape on the page. Because names must be unique Visio gives the following names:
Name: Box.7 (number is only an example)
NameU: Box.7
NameID: Sheet.7
ID: 7
Now you rename that second shape to "MyBox" / or like you did to "MyBox.7"
Name: MyBox /MyBox.7
NameU: MyBox /MyBox.7
NameID: Sheet.7
ID: 7
Now different things can happen. First example you change the name a secon time, e.g. to "MyNewShapename". Look what happens to NameU.
Name: MyNewShapename
NameU: MyBox
NameID: Sheet.7
ID: 7
Nothing happens to NameU, only the first renaming changes Name and NameU. Every additional renaming only changes Name.
!!!But: Only NameU (or NameID) can now be used for reference in ShapeSheet, so you see a name in ShapeSheet and search for the shape, but you don't find it, beause you look for the Name, but the Name is not the same as NameU anymore!
Therefore the NameU macro searches for the NameU as that is the name in the ShapeSheet.
In case the reference in the ShapeSheet is with the NameID (e.g. Sheet.123) the other macro searches for the shapes via NameID.
Another thing that can happen, is that Visio changes the ID (like you mentioned):
Name: MyBox /MyBox.7
NameU: MyBox /MyBox.7
NameID: Sheet.325
ID: 325
----------
I mentioned above, that names must be unique. That was not quite correct. They must be unique for all shapes and groups on the page. But sub-shapes inside a grouped shape must only be unique inside that group (if I recall correctly). That means a subshape in group 1 can eventually have the same name as a subshape in group 2.
It may be, that the NameID must be unique nevertheless, but I'm nut sure about that.
----------
To drill down into the groups a little change to the code is needed, added a search for just the ID, too. Maybe it helps.
If you want to search for Name, too, it should be easy for you add a fourth code section in copiing the NameU code and deleting the U everywhere ;-)
'*****************************************************
'Search for NameID:
Sub SearchNameID()
Dim shp As Visio.Shape, Dim s As String
s = InputBox("Enter ShapeName+ID like Sheet.123")
ActiveWindow.DeselectAll
For Each shp In ActivePage.Shapes
SNID(shp,s)
Next
If ActiveWindow.Selection.Count = 0 then MSGBOX("No Shape found")
End Sub
Sub SNID(shp as Shape, s as String)
Dim Subshp as Shape
If shp.NameID = s Then
ActiveWindow.Select shp, visSelect
End If
For Each subshp in shp.Shapes
SNID(subshp,s)
Next
End Sub
'*****************************************************
'Search for NameU:
Sub SearchNameU()
Dim shp As Visio.Shape, Dim s As String
s = InputBox("Enter ShapeNameU like MyShapesName")
ActiveWindow.DeselectAll
For Each shp In ActivePage.Shapes
SNU(shp,s)
Next
If ActiveWindow.Selection.Count = 0 then MSGBOX("No Shape found")
End Sub
Sub SNU(shp as Shape, s as String)
Dim Subshp as Shape
If shp.NameU = s Then
ActiveWindow.Select shp, visSelect
End If
For Each subshp in shp.Shapes
SNU(subshp,s)
Next
End Sub
'*****************************************************
'Search for ID only:
Sub SearchID()
Dim shp As Visio.Shape, Dim s As String
s = InputBox("Enter ID like 123")
ActiveWindow.DeselectAll
For Each shp In ActivePage.Shapes
SID(shp,s)
Next
If ActiveWindow.Selection.Count = 0 then MSGBOX("No Shape found")
End Sub
Sub SID(shp as Shape, s as String)
Dim Subshp as Shape
If shp.ID = s Then
ActiveWindow.Select shp, visSelect
End If
For Each subshp in shp.Shapes
SNID(subshp,s)
Next
End Sub
hth Jumpy