Background Size

Started by ben.oates, April 29, 2009, 04:52:20 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ben.oates

Hi all,

I have a background with 3 small logos on it.

I have set these logos up to space themselves evenly across the page regardless of how big the page is.

What I need to know is, when this page is set as a background, is it now possible to make that page stretch to match the size of whatever foreground page is using it so that these images will always space evenly across the top?

Many thanks,

Ben

wapperdude

The background page does not normally scale to the foreground page, nor does it match the orientation.  Don't believe there is any existing automation for this.  Your options would be 1.) to make multiple backgrounds for the desired sizes and orientations, or 2.)  perhaps create some code that recognizes the foreground page and adjusts the background appropriately.

There is a danger with the second approach.  If two different (size and/or orientation) foreground pages reference the same background page, one of the two will have an incorrect background setting.  I think step 1.) would be quicker, easier, and less risky.

Wapperdude
Visio 2019 Pro

Visio Guy

The page has a ShapeSheet which controls its size, along with other characteristics.

You can refer cells in a background page to cells in a foreground page. So, for the background, you could have something like:

PageWidth = Pages[Page-1]!ThePage!PageWidth
PageHeight = Pages[Page-1]!ThePage!PageHeight

The problem is when you add another foreground page. Then the background will only follow "Page 1", and ignore page 2, 3, 4...

So this solution is only good for single-page documents. There are plenty of applications that require only one page, so this may be useful nevertheless.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vojo

you might be able to pull this off with just using the "thepage" reference.
Ie since you select backup page when inserting new foreground page....and "thepage" references the
current page, this foregrnd page would set it.   Now I am not sure if you try to play some games where
each foreground page is a different size (may not be able to evenly do that)...if this works.

If you want individual sizes per foregrnd.   You could do group of shapes for background, use event on drop cell to pull up some custom properties that would set the size.   something like

width = prop.width_ratio * default width.

If you use the guard function....you would not be allowed to accidently change shape size or move
(same as the protection stuff).

With protections for size, location, format....probably dont need to worry about selecting inadvertently
protection against delete should make sure you do loose it.

I am not too fluent with layers...but you could use layering to help with this (backgrounds on 1 layer foregrnd on another.....hide background until finished....then enable).

finally, if you really want to go where few have gone...you could look at a drop down to define which foregrnd sets the size.   Use quotes and getval to define the "[1]" piece of the equations above. 
Wont kid you...this will end up being real subtle to achieve and may be more work than is worth it.

Just some thoughts.

ben.oates

Thanks for the feedback guys. All very helpful.

Unfortunately, this will be a multi-page document with pages of different sizes. However, the images will be evenly spaced across the edges of the document so a combination of your feedback has given me a new idea/problem.

If I made these images space themselves in the ShapeSheet, used the GUARD function and turned them into a Stencil of some kind, how could I make Visio add this named stencil to every new page?

This way, I could remove background pages completely and the images I need people to include would be enforced nonetheless. It might make file sizes a bit bigger but that's not a concern.

Thanks again.

aledlund


ben.oates

Thanks aledlund. I managed to cobble together something similar, except it drops itself on the PageAdded event.

In case this helps people in the future, my master does many of the things mentioned in that link through code:

Private Sub Document_PageAdded(ByVal Page As IVPage)
    Set masShape = ActiveDocument.Masters.ItemU("Background Images")
    Set bgShape = ActivePage.Drop(masShape, 0, 0)
    bgShape.CellsU("Width") = 0
    bgShape.CellsU("Height") = 0
    bgShape.CellsU("PinX") = 0
    bgShape.CellsU("PinY") = 0
    bgShape.CellsU("LocPinX") = 0
    bgShape.CellsU("LocPinY") = 0
    bgShape.CellsU("LockTextEdit") = 1
    bgShape.CellsU("NoObjHandles") = 0
    bgShape.CellsU("LockSelect") = 1
    bgShape.CellsU("LockMoveX") = 1
    bgShape.CellsU("LockMoveY") = 1
    bgShape.CellsU("LockDelete") = 1
    bgShape.CellsU("SelectMode") = 0
    bgShape.CellsU("DisplayMode") = 1
End Sub

The "Background Images" master is made up of 3 images that cannot be stretched - but have GUARD set on their location to make them spread out top left, center and right of the page against ThePage PageHeight and PageWidth. When the master is added, you have to move it to the bottom left otherwise it still offsets the 3 images contained within. I made it 0 height and width so that nobody would click it.

Thanks for the help guys.

Visio Guy

I usually make some sort of "foreground title block" shape in these circumstances. You can set size and position formulas such that the shape automatically fits the page onto which you drop it.

For instance, a "header" shape might have formulas like this:

LocPinX = GUARD(0)
LocPinY = GUARD(Height)
PinX = GUARD(0.25in)
PinY = GUARD(ThePage!PageHeight-0.25in)

Note: 0.25in is a margin to keep the shape off the non-printable edges.

There is more information on fixing a shape's position on an arbitrary page in this article:
Number Your Pages Visually
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

Yacine

#8
I faced a similar problem, having to set the drawing frame of multipe page drawings.

The solution is quite simple, but requires either some disciplin from your users (that's the way we chose) or to block the edition of certain page properties (--> guards in the shape sheet).
We ask our users to change ONLY the drawing scale when they wish to adjust the page size. That works pretty fine.
In the enclosed example, you'll notice that the 500x200 mm rectangle has a quite different size on page 1 and 2.
You'll see also that font sizes don't depend on the page scale (both page names have font size 60 and the same size). You'll overcome this problem by using text shapes with font sizes that depend on their height.

The 3 shapes of the background have the same look on both foreground pages as required.
Yacine

wapperdude

You were actually able to have users that were disciplined?     ???  Wow!   :o
Visio 2019 Pro

AndyW

I adjust the background to fit my current page, using the WindowTurnedToPage event.


Private Sub myVsoApp_WindowTurnedToPage( _
    ByVal Window As IVWindow)
   
    Dim vsoPage As Visio.page
    Dim vsoBackPageSheet as Visio.Shape

    Set vsoPage = Window.page

    Set vsoBackPageSheet = Window.Document.Pages("BACKGROUND").PageSheet
   
    With vsoPage.PageSheet
   
        vsoBackPageSheet.CellsU("PageWidth").FormulaU = .CellsU("PageWidth").FormulaU
        vsoBackPageSheet.CellsU("PageHeight").FormulaU = .CellsU("PageHeight").FormulaU
       
    End With
     
End Sub
Live life with an open mind

Yacine

Quote from: wapperdude on May 12, 2009, 05:13:45 AM
You were actually able to have users that were disciplined?     ???  Wow!   :o
Actually yes. Let them distroy 2 or 3 drawings and direct them to your tutorial as only answer.
Very educative ;D (the sadist in me)
I have to add, that I have only abt. 10 people to handle.
Yacine

Yacine

#12
Quote from: ben.oates on May 11, 2009, 10:39:41 AM
Unfortunately, this will be a multi-page document with pages of different sizes.
With your code all the pages should get the same size  ???
Yacine