Visio Guy

Visio Discussions => General Visio => Topic started by: bobfirth on May 18, 2010, 10:47:32 PM

Title: Copy standard items when you insert new page
Post by: bobfirth on May 18, 2010, 10:47:32 PM
I would like to be able to create a template which copies some standard items every time a new page is inserted. This would be the same as what happens with functional bands in the cross functional flowchart. Is this possible?

Bob
Title: Re: Copy standard items when you insert new page
Post by: Visio Guy on May 19, 2010, 11:38:45 AM
Hi Bob,

A few options/ideas:

1. Use a background page, if no interaction is needed with the standard items. The background page can "show through" to each new page added.
2. Create a master shape that can be dragged out that contains all of the standard items. Note: this will result in one main group that may need to be ungrouped if you need access to individual items.
3. Code: the document object has a page added event. This is what you'll need to use for anything that is sophisticated. Not sure if you are comfortable with code or VBA.
Title: Re: Copy standard items when you insert new page
Post by: bobfirth on May 26, 2010, 11:40:10 PM
Thanks for the ideas.

Users need to be able to change text per page, so BG page is no go.

I want it to become part of the title block, so maybe a master with GUARD() on the X,Y would do it.

It would be nice if it happened without the users remembering to put it in though, in which case VBA sounds like the best solution. I am happy to code where necessary, although I have only done a little bit of VBA in Visio before. Can you guide me towards the code that would insert my master shape(s) onto the drawing when a page is added?
Title: Re: Copy standard items when you insert new page
Post by: geh_heim on May 27, 2010, 06:03:18 AM
i think the Document_PageAdded would do right ?

you could even add the the page via Makro if you want, for the code how to drop the Shape just record it once.
Title: Re: Copy standard items when you insert new page
Post by: bobfirth on June 03, 2010, 06:48:54 AM
I am a beginner at VBA in Visio, can you point me to a tutorial that would explain how to access the page events?
Title: Re: Copy standard items when you insert new page
Post by: geh_heim on June 07, 2010, 06:10:16 AM
sry i don't have any tutorial (learning by doing is my style ^^)

the document and page are easy to find.
oben the VBAWindow, then open the "ThisDocument" vba, on the top you will see 2 dropdown menus.
choose "Document" from the left and then you can see all Events available in the right dropdown.
Title: Re: Copy standard items when you insert new page
Post by: bobfirth on June 08, 2010, 12:58:59 AM
Perfect, that's enough to get me started, I'll report back if I get any further. Thanks for your help.
Title: Re: Copy standard items when you insert new page
Post by: bobfirth on June 08, 2010, 05:25:20 AM
I have achieved what I need with the following code:

Private Sub Document_PageAdded(ByVal Page As IVPage)
    Page.Drop ThisDocument.Masters.ItemU("MasterName"), 0, 0
End Sub

Where MasterName is the name of the master in the document stencil.

Although 0, 0 refers to the location, the master has GUARD() around PinX and PinY to ensure that it always lands (and stays) in the right position because it is part of the title block.