Zebra125
Zebra125

Reputation: 526

How delete all .png shapes in active window visio ? VBA

I would like do detele all picture png from an active window from MS Visio in VBA so I tried this:

Sub DeleteAllShapes()


    Dim vsoSelection As Visio.Selection
    Set vsoSelection = ActiveWindow.Selection

Dim shp As Shape

For Each shp In vsoSelection
  If shp.Type <> msoPicture Then shp.Delete
Next shp

End Sub

But it deletes just the last select and not all in the page

Upvotes: 0

Views: 125

Answers (1)

Paul Herber
Paul Herber

Reputation: 1200

When deleting shapes you need to use a plain For loop and count backwards.

For shp = vsoSelection.Count To 1 Step -1
  more code
Next shp

Upvotes: 1

Related Questions