Centering the Executive in and Org Chart

M

Mike S

I am using Visio 2003 and would like the Excecutive shape to be centered in
on the page, regardless of how the subordinate shapes are arranged. I have
tried setting the PINX postion in the shapesheet to
=GUARD((ThePage!PageWidth)/2) and this centers the shape, but the shapesheet
changes from a formula to a Value and the centering is not retained as I
resize the drawing page. Is there any way to force the excecutive shape to
always remain centered? Alternately, is there any way to move the position
of the executive shape left and right without moving the entire drawing?
 
W

wouter

Hi Mike,

The cell PinX is protected
Even if you would remove all the subshapes you still can't put a formula in
At that stage however you can add a shape
put that shape at the back
group the shape and put the formula in the newly added shape
then the formula can be added
however back to the original executive shape
you will see that you can't perform the grouping operation
you might opt to add a shape on the page and use the hittest command get
the job done

what you can do however is add a customer property
and put the formula in its value cell
then add a user cell with the formula
"=setref(getref(PinX), Prop.Pinx)"
this will update your PinX cell
the drawback however is that you can't set 'portrait' and landscape' in page
setup
you have to set the pagesize physically through the page shapesheet
why does this work?
because you port a value to the PinX cell instead of a formula

René
 
M

Mike S

That technique works when I first set the custom property and user cell in
the shapesheet, but when I close the shapesheet, I can then move the
exectutive shape around, and it is not returned to center. Is there any way
to force the shape to stay centered, or to refresh PinX location without
reopenening the shapesheet?
 
W

wouter

Hi Mike,

To completely force the shape in the middle
do the following
(the drawback is that you can't move the shape after that though)

1. create macro to set the pinx and piny
2. run macro from shapesheet with following command
"=RUNMACRO("ThisDocument.setXY")"
in the eventxfmod cell

The result is that after you have run the macro the formulas:
"GUARD((ThePage!PageWidth)/2)" and
"GUARD((ThePage!PageHeight)/2)"
are forced into the PinX and PinY cells so you can remove the macro

macro:
Sub setXY()

Dim vshape As Visio.Shape
Dim vshapes As Visio.Shapes
Dim vpage As Visio.Page
Dim cellobj As Visio.Cell
Dim cellobj2 As Visio.Cell
Dim fullcount As Integer
Dim i As Integer
Dim d As Double
Set vshapes = ActivePage.Shapes
fullcount = vshapes.Count
For i = 1 To fullcount
Set vshape = vshapes.Item(i)
If Mid(vshape.Name, 1, 9) = "Executive" Then
Set cellobj = vshape.Cells("PinX")
cellobj.FormulaForceU = "GUARD((ThePage!PageWidth)/2)"
Set cellobj2 = vshape.Cells("PinY")
cellobj2.FormulaForceU = "GUARD((ThePage!PageHeight)/2)" '
End If
Next i
End Sub

Best of luck

René
 
M

Mike S

That works perfectly! THANKS!

wouter said:
Hi Mike,

To completely force the shape in the middle
do the following
(the drawback is that you can't move the shape after that though)

1. create macro to set the pinx and piny
2. run macro from shapesheet with following command
"=RUNMACRO("ThisDocument.setXY")"
in the eventxfmod cell

The result is that after you have run the macro the formulas:
"GUARD((ThePage!PageWidth)/2)" and
"GUARD((ThePage!PageHeight)/2)"
are forced into the PinX and PinY cells so you can remove the macro

macro:
Sub setXY()

Dim vshape As Visio.Shape
Dim vshapes As Visio.Shapes
Dim vpage As Visio.Page
Dim cellobj As Visio.Cell
Dim cellobj2 As Visio.Cell
Dim fullcount As Integer
Dim i As Integer
Dim d As Double
Set vshapes = ActivePage.Shapes
fullcount = vshapes.Count
For i = 1 To fullcount
Set vshape = vshapes.Item(i)
If Mid(vshape.Name, 1, 9) = "Executive" Then
Set cellobj = vshape.Cells("PinX")
cellobj.FormulaForceU = "GUARD((ThePage!PageWidth)/2)"
Set cellobj2 = vshape.Cells("PinY")
cellobj2.FormulaForceU = "GUARD((ThePage!PageHeight)/2)" '
End If
Next i
End Sub

Best of luck

René
 

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