Help With Boundingbox Method To Work

G

Gary

I am trying to select all objects bounded by coordinates on a page.

I was trying to use BoundingBox Method and it seems not to work for me.
Could it be my x and y coordinates on the right, left, bottom, and top?? I
have a 8.5x11 sheet of paper and its broken up into 15 rectangles. I use the
size & position window in Visio to get the x and y coordinates in inches.

Can someone help here!!!

Below if the VBA Macro from Visio that I was using to test. The PagObj is
P1 which is the page 1 of the visio document. I am trying to select all
objects given in the coordinates of .6" from the left side, 8.4" down from
the top, 3.05" on the right side, and 10.54" from the top.

When I view my visio document, nothing was selected. No error to my
knowledge.

Can someone help !

Thanks,


Gary





Sub Macro1()
Dim x As String
Dim DocObj As Visio.Document
Dim PagsObj As Visio.Pages
Dim PagObj As Visio.Page

Set DocObj = ActiveDocument
Set PagsObj = DocObj.Pages

For Each PagObj In PagsObj
ActiveWindow.Page = PagObj.Name
z = ActivePage.Shapes("Fm.1").Text
Debug.Print z

PagObj.BoundingBox visBBoxExtents, 0.6, 8.4, 3.05, 10.54
Next PagObj
End Sub
 
D

David Parker

Pardon me, but I don't see what line in your code is supposed to select
anything?
The BoundingBox method returns the co-ordinates of rectangle respecting the
arguments.
It does not create a selection, nor does it draw a rectangle.
You probably want to use DrawRectangle, SpatialNeighbors, Select, then
delete the rectangle.
 
G

Gary

I thought that the boundingbox will return a rectangle that is the smallest
rectangle that encloses the shapes?? (according to the vba on line help)?
All I want to do is to create a selection of those coordinates.

I could be wrong.

Additional clarification anyone???


Thanks,

Gary
 
J

J Kallay

Gary, BoundingBox does the exact opposite of what you're trying to do: given
a selection (that is, a set of selected shapes), it returns the corners of a
bounding box containing that selection.
David's suggestion is to create a rectangle representing your bounding box,
and then call its SpatialNeighbors property to select all shapes that are
within that rectangle.
 
G

Gary

I still need a little help. I have change the VBA code to create a rectangle
and I see it covering the desired area. Under the rectangle are 8 little
circles or objects.

I got the DrawRectangle to work correctly, but the spatialNeighbors is
return 0 for the vsoSelection. What am I doing wrong???

It will not let me dow this statement, Set vsoGroup = vsoSelection.Group.
I think it may be due to the fact vsoSelection has 0

The code is shown below:

Dim x As String
Dim DocObj As Visio.Document
Dim PagsObj As Visio.Pages
Dim PagObj As Visio.Page
Dim vsoShape As Visio.Shape
Dim vsoSelection As Visio.Selection
Dim vsoGroup As Visio.Shape

Set DocObj = ActiveDocument
Set PagsObj = DocObj.Pages

For Each PagObj In PagsObj
Set vsoShape = ActivePage.DrawRectangle(0.6, 10.54, 3#, 8.48)
Set vsoSelection = vsoShape.SpatialNeighbors(visSpatialFrontToBack,
0.05, 0)
Set vsoGroup = vsoSelection.Group
ActiveWindow.Select vsoGroup, visSelect
Next PagObj

I appreciate any help !!

Thanks,

Gary
 
G

Gary

Thank You All !!!!

I finally go it to work. It was the spatialNeighbors parameters.


Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top