Trouble with Copy/Paste

D

David LACASSAGNE

Hello,

I generate Visio drawings from an Access DB with the following
process:
1-Generate a Temporary directory for each drawing
2-Copy Stencil file to the temporary directory of step 2
3-Open Stencil file with Visio, change masters caption with DB
contents, save it and close
4-Generate a Visio drawing by automation from DB contents using drop
operations from the stencil file.

So, if I generate 2 drawings, they are based on 2 different stencil
files (masters have the same BaseID, but different UniqueID).

Let's take the following sample:
- Drawing1 is composed of Shape1 based on the master named MASTER
(from Stencil1)
- Drawing2 is composed of Shape2 based on the master named MASTER
(from Stencil2)

MASTER has the 'Match master by name' property set to True.

So, when I drag MASTER from Stencil1 To Drawing2, I get Shape3 that is
based on MASTER.

But If I copy Shape1 and paste it to Drawing2, I get Shape4 that is
based on a new master (added to the Drawing2 document stencil) called
MASTER.2

Is there a way to avoid this new master creation ? Or in the
SelectionAdded event, a way to change the Shape4 master and then
destroy MASTER.2 ?

Thanks in advance,

David.
 
C

Chris Roth [ Visio MVP ]

Master Properties have an attribute called "match master by name on drop",
you get this by right-clicking on a master shape.

The first time MasterX is dropped into a drawing, it gets copied to the
drawing, of course. If you drag a different MasterX, from a different
stencil, perhaps generated at a different time, and having different
characteristics, you'll simply get an instance of the very first MasterX,
because of the "match by name" attribute.

It's an "oldest version wins" scenario.

Normally, Visio generates a super-secret date-time stamp every time you edit
a master. It compares these when masters are dragged from external stencils
into Visio documents. If two MasterX's have different date-time stamps, then
Visio renames the newcomer to MasterX.2 or something similar.

--

Hope this helps,

Chris Roth
Visio MVP
 
D

David LACASSAGNE

Chris, thank you for your answer.

I use this "match by name" attribute, and the "oldest version wins"
scenario is perfectly OK for me.

The trouble is that the "Match by name" works perfectly when dragging
from external stencils (even modified ones) : in my example (see msg
#1 of the thread), using Stencil1 or Stencil2 for Drawing2 never
creates a new master.

But the "Match by name" no longer works if I paste a shape from a
document created with another stencil (in my example copy from
Drawing1 to Drawing2). This the only case I am trying to solve.

If there are no solutions to modify this Visio behaviour, does anybody
have a solution to correct it by post processing ?

The only one I see up to now is:
- In the "Selection Added" event, test if the Selection object
contains shapes based on duplicated masters
- If yes, drop the "good" corresponding masters from my document
stencil to create the shapes, then copy all attributes (in fact, a
kind of duplication with changing the masters !!)
- Delete the selection
- Delete the duplicated masters

Maybe other solutions could be (but I don't know if they can be done
!!):
- Look into the clipboard and modify it ?
- Change the master property of each pasted shape ? (overrive Read
only protection of this property ?)

Can someone help me ?

David.
 
C

Chris Roth [ Visio MVP ]

God, I thought I knew just about everything masters and instances, but this
is a suprise - the copy / paste not picking up the master.

You can probably trap the ShapeAdded event, and then inspect the clipboard.
Graham Wideman's book (www.diagramantics.com) describes what's in the Visio
clipboard quite well.

More simply, you could just ask about the name of the new master, then do
what Visio is supposed to do, ie: match by name: replace the newcomer,
delete the 'master.2' master that was added...

--

Hope this helps,

Chris Roth
Visio MVP
 
D

David Parker

Just an observation:
I have noticed that Match Mavter By Name does not work when the shape name
inside the master is different.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top