BB code in posts seems to be working again!
I haven't turned on every single tag, so please let me know if there are any that are used/needed but not activated.

Main Menu

[Tutorial] Background text changes depending on the frontpage used

Started by Lars-Erik, April 24, 2008, 06:48:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Background info:

What i needed was a way to display text on the background that would be different depending on the foreground. Cause the border and title block of my drawings need to change when the paper size is changed, I made backgrounds containing the border and title block. Each of my Visio files contains two pages. The problem occurred when both the drawings in the Visio file are using the same background, they will have the same data in there title blocks. To get past this problem i had to find a way to make the text change depending on the foreground.

Using the Visio UI I was able to make a shape display the background page name as text. The command for this according to the ShapeSheet of the shape was =BKGPAGENAME(). After some searching on the MSDN site i found a command that looked alot like it, =PageName(). After trying this command i noticed this did exactly what i had hoped. If you put this command on a background it will show the name of the current page, if the current page happens to be a foreground page it will show that name.

A simple second step would be to make an if statement change the text depending on the =PageName() command and you would be done. This however turned out to be a bit harder then I hoped. After creating the if statement i noticed that it doesn't play nice with strings. Because i don't want to name my pages 1 and 2. I got around it bij naming them 1; Pagename and 2; Pagename. Cause I don't want to force someone to add unwanted data in there page name. A solution would be to replace the PageName() with PageNumber(). If you alter the if statement to check for the page index.

The code:

So, here goes add custom properties to your document. These will function as a source for our data. (what will be displayed).
Example: The User.Properties is "PFD Description;P&ID Description;PFD Drawing no.;P&ID Drawing no.;Proj. no.;Order no.;Customer name"

Now on every background you have. Add the following text field


It checks what page is showing, if its page with index 1, it will get the documents User.Properties field. The index command will make it sellect the first (0 ;'s) data it finds. If its not the first page it will get the 2nd data (1 ;'s ).

In this case the text field will show PFD Description on page with index 1, and P&ID Description on the page with any other index.
If you have more pages you will have to add more if statements.

Fairly straight forward, though for some reason I find it hard to explain clearly. If you cant get it to work let me know!
!!!This code will check for page order changing the page order will mess up the effect of this code!!!

Check the tutorial on preventing unwanted user input to lock the page order

Also for some further help:

Browser ID: smf (possibly_robot)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 158 (show)
Files included: 32 - 1207KB. (show)
Memory used: 1001KB.
Tokens: post-login.
Cache hits: 15: 0.00221s for 26,766 bytes (show)
Cache misses: 3: (show)
Queries used: 16.

[Show Queries]