Hi,
any idea what's wrong with this code (which should delete all layers which have "<>" in it):
Set Layers = Visio.ActivePage.Layers
For Each layer In Layers
If InStr(layer.Name, "<>") > 0 Then
layer.Delete (0)
End If
Next
What happens is that only a few of the layers are delete without any error. I can run this code again and again and always are a few layers removed and at some point in time all are gone... I bet this code already worked a while ago but now it doesn't...
Any idea?
Thanks,
Thomas
If, say, layer1 gets deleted then what was layer2 then becomes layer1. But the looping doesn't know that so moves on to the new layer2, missing out what is now layer1.
You need to use a normal FOR loop but work backwards through the count.
THANKS so much!!!
Thomas