1
votes

Is it possible to select shapes in Visio by specifying the coordinates of a selection rectangle? If so, how does one do this? I need to select and delete any shape in a specific location on a Visio page. I would like to be able to specify the coordinates of a lower left corner and an upper right corner on the page and have vba tell me the id's or handles or something that would allow me to delete these shapes as I need to place a new shape in that particular location. I am looking for something like

shapes = MyVisioPage.SelectByRectangularCrossingBox(lowerleftX,lowerleftY,upperrightX,upperrightY)
1
Not that i know of. You can loop through all the shapes and analyse the position of them and delete them if they fall in your "area".MatthewD

1 Answers

0
votes

You could actually draw a rectangle with those coordinates and then use Shape.SpatialNeighbors to find out all shapes in that rectangle.. Something like this (VBA):

Function SelectByRectangularCrossingBox(page, _
    lowerleftX, lowerleftY, upperrightX, upperrightY) As Selection

    scopeId = page.Application.BeginUndoScope("try")

      Set rc = page.DrawRectangle(lowerleftX, lowerleftY, upperrightX, upperrightY)
      Set SelectByRectangularCrossingBox = rc.SpatialNeighbors(visSpatialContain, 0.01, 0)

    page.Application.EndUndoScope scopId, False

End Function

The code is wrapped around with BeginUndoScope/EndUndoScope to cancel changes.