How do Borders and Title shapes stretch to fit the page?

When dropping a border or title shape on a page, it automatically stretches to fit the page, but if you look at the shapesheet for the dropped shape, Width and Height are fixed. How do they do that?


The trick is that the shape on the stencil has an EventDrop cell that tells Visio to set the values of Width, Height, PinX and PinY to fixed values when the shape is dropped on a page. It also tells Visio to clear the EventDrop cell so the process can not be repeated by the copy.


You can find samples of these shapes by looking in the “Background” “Border and Titles” stencils. When you look ath these shapes, you will find that these shapes define their size based on the page size using the following formula:

Width =ThePage!PageWidth-4*User.PageMargin
Height=ThePage!PageHeight-4*User.PageMargin
PinX=ThePage!PageWidth*0.5
PinY=ThePage!PageHeight*0.5

The value for the PageMargin row in the User Section is a bit involved to repeat here, but it sets the margin off the shape based on the scaling factors in use.


The EventDrop cell uses SETF and GETF to assign the initial formula to the four cells and then replace it with the formulas value. I have broken the formula into its’ five components to make it more readable. In reality, the formula in the EventDrop cell below is one long string. 

=SETF(GetRef(Width),ThePage!PageWidth-4*User.PageMargin)
+SETF(GetRef(Height),ThePage!PageHeight-4*User.PageMargin)
+SETF(GetRef(PinX),ThePage!PageWidth*0.5)
+SETF(GetRef(PinY),ThePage!PageHeight*0.5)
+SETF(“EventDrop”,0)

 The final SETF clears the EventDrop cell.


A similar method is used for Background pages, but the formulas are not cleared


Width =GUARD(ThePage!PageWidth)
Height=GUARD(ThePage!PageHeight)
PinX=GUARD(Width/2)
PinY=GUARD(Height/2)


Unlike the Borders and Titles shapes, the Background shape needs to run an add-on to place the shape. The EventDrop cell contains:


=RUNADDON(“Make Background”)+SETF(“EventDrop”,0)


The “Make Background” is a Private add-on which will create a background page called VBackground, place and resize the shape and then add the background page reference to the foreground page.


John…    Visio MVP

The Bowness of a Circular Arc

To create a circular arc in a shapesheet’s Geometry section, requires the specification of where the arc ends and a cell called “A” that holds the measurement of how much the arc differs from a straight line between the end points of the arc. The deflection indicates how much the arc bows. It is possible to fragment a circular shape to get an idea of a value of “A”, but it is a value not a formula.


So what is a formula to describe the content of the “A” cell? To determine a formula, you need to revisit your grade school trigonometry notes. A line that connects two points a circle is called a chord and has a few special properties. The largest chord passes through the center of the circle and is called the diameter. A triangle formed by the chord and the center of the circle forms an Isosceles triangle. The angles at either end of the chord are identical. If you use the half way point on the chord, call it B, to bisect the triangle through the center of the circle, call it C, you end up with two identical right angles triangles.


The length from B to C divided by the hypotenuse of the right angle triangle is the sine of the angle of the right angle triangle at the center of the circle. In this case, the hypotenuse is the radius of the circle and the angle is half the value of the angle formd by Isosceles triangle.


So the length of BC is:  Radius x Cosine (angle/2).  


So the formula for cell “A” is:  Radius – Radius times Cosine (angle/2)  or Radius (1 – Cosine(angle/2))


John… Visio MVP