Copy standard items when you insert new page

Started by bobfirth, May 18, 2010, 10:47:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bobfirth

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

Visio Guy

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.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

bobfirth

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?

geh_heim

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.

bobfirth

I am a beginner at VBA in Visio, can you point me to a tutorial that would explain how to access the page events?

geh_heim

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.

bobfirth

Perfect, that's enough to get me started, I'll report back if I get any further. Thanks for your help.

bobfirth

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.