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:
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.
The final SETF clears the EventDrop cell.
A similar method is used for Background pages, but the formulas are not cleared
Unlike the Borders and Titles shapes, the Background shape needs to run an add-on to place the shape. The EventDrop cell contains:
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