Layout shapes on a page

D

dave

Hi All,

I've really new to visio vba. What I want is automation of the 'drop' of
masters stencils onto a page. The shapes are basic rectangles My problem is
the size(width) of each master. I wish to lay them out end to end across
the page. I know the following code need some help. What I think it needs
is the pin x and pin y of the selected master stencil prior to being
dropped. I don't know how to access the master shape Pin x and Pin y
value with VBA. Any help would be appreciated


Dave


Sub Assembly()


Dim MoveAmount As Integer
Dim Frames As New Collection
Dim vsoShapeDone As Visio.Shape
Dim vsoSelection As Visio.Selection
Dim vsoPages As Visio.Pages
Dim vsoPage As Visio.Page
Dim vsoMaster As Variant
Dim vsoDocument As Visio.Document
RightHere = 57


Application.Windows.ItemEx("TheTarget").Activate

For I = 2 To 6
vsoMaster = "Master." & I

Set vsoShapeDone =
ActivePage.Drop(Application.Documents.Item("TheStencils.vss").Masters.ItemU(vsoMaster),
RightHere, 59)
MoveAmount = vsoShapeDone.CellsU("Width")
RightHere = RightHere + MoveAmount

Next I
End Sub
 
J

junethesecond

Your code works well.
Cordinate (57,59) means (57 in, 59 in) in VBA, so , in my Visio, I had to
set drawing scale to 1/50 to see the result.
And "TheTarget" had to be changed into "TheTarget.vsd".

For example..
Sub Assembly2()

Dim MoveAmount As Integer
Dim vsoShapeDone As Visio.Shape
Dim vsoPage As Visio.Page
Dim vsoMaster As Visio.Master
Dim RightHere As Long
RightHere = 57

Application.Windows.ItemEx("TheTarget.vsd").Activate

For Each vsoMaster In Documents("TheStencils.vss").Masters
Set vsoShapeDone = ActivePage.Drop(vsoMaster, RightHere, 59)
MoveAmount = vsoShapeDone.CellsU("Width")
RightHere = RightHere + MoveAmount
Next
End Sub
 
D

dave

Hi June

Thanks for the reply and the pointers about my code. I'm using V2003. What
I'm trying to do is layout every rectangle end-to-end without overlap or
space between each of the shapes. Here my example

The 5 Master stencils have the the respective widths 12, 15, 17, 24 amd 57
inches

If the layout sequence is Masters 1, 5, 1, 5

My code does the following:

First Drop Shape1(Master.1) arrives at RightHere = 57
Then RightHere = 57 + 12 = 69
The second Drop of Shape2(Master.5) overlaps Shape1(Master.1)
Then RightHere = 69 + 57 = 126
After the third Drop there is a space between Shape2(Master.5) and
Shape3(Master.1)
and so on...


What is needed is the "Width" of the Selected Master (before it is dropped).
Can I access the CellU("Wdith") of a selected Master? If so, How?
Any help is appreciated.

Dave
 
J

junethesecond

Width of master is able to obtain with master.shape.Cells property.
Your righthere can be got by adding width*0.5 of new shape and last
dropped shape.
For example,
Dim MoveAmount As Double
Dim vsoPage As Visio.Page
Dim vsoMaster As Visio.Master
Dim RightHere As Double
RightHere = 57

Application.Windows.ItemEx("TheTarget.vsd").Activate

For Each vsoMaster In Documents("TheStencils.vss").Masters
MoveAmount = vsoMaster.Shapes(1).CellsU("Width") * 0.5
RightHere = RightHere + MoveAmount
ActivePage.Drop vsoMaster, RightHere, 59
RightHere = RightHere + MoveAmount
Next
 

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