Help With a simple shp.Delete when accessing MyShapes

Started by DinoCobolMan, August 14, 2017, 10:51:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DinoCobolMan

I have customized shapes of just circles and squares that contain text.  They are all saved under My Shapes.   The shape "Root1" is contained in My Shapes in "VBA intervals".  The shape "Root1" under the Shape Sheet it is also named "Root1".   The attached code above will not delete "Root1", but when I rename "Root1" to "jazz'" every shape named "jazz" will be deleted from my Actitive Page.   When I check the Shape Sheet, the shape named "jazz" is STILL named "Root1".   Since the code will actually delete "jazz", I assume that the code is correct, but please feel free to correct my assumption.  The name "Root1" has been in the same stencil in My Shapes since 2014, but I haven't tried to run any of my sub routines since 2014.   Have any of you seen this before? 

I am using Visio 10 that is installed as 64-bit. 

Public Sub DeleteCats()
Dim shp As Visio.Shape
Dim i As Integer
'
ActiveWindow.DeselectAll
For i = ActivePage.Shapes.Count To 1 Step -1
    Set shp = ActivePage.Shapes.ItemU(i)
     If Not (shp.Master Is Nothing) Then
'       If shp.Master.Name = "Root1"  Then       '// will not delete
         If shp.Master.Name = "jazz"  Then        '// Delete works
                 shp.Delete
         End If
     End If
Next i
End Sub

wapperdude

Add:  debug.print  shp.master.name right after the "if" statement, before the delete statement to verify the master name.

Wapperdude
Visio 2019 Pro

DinoCobolMan

Waperdude, thank you for responding to my forum posting.

The problem with my code was between my chair and my keyboard.     ;D

I installed Vision 2016, tried to save my old VBA document and,  I received that warning that I needed to save my document as a "Visio Macro-Enabled Drawing" or ".vsdm" format. 

All my code old code is working now. 

wapperdude

Ah!  That problem.  😱. When you find a cure, let us know, seems to be common and plagues a lot of users.  😵  😰   ;D
Visio 2019 Pro