Stencil loading time

R

Robert Lelieveld

Hi,

Loading my custom stencils (about 8 stencils) takes a 'long' time, so I'm trying
to shorten the loading time.

The stencils are loaded with a visio drawing and docked to the drawing window.
Is it possible to undock the stencils and redock them again when another drawing
is loaded? Ultimately loading the stencils at Visio's startup and (un-)docking
the stencils when appropiate.

I can close the stencils, but then they have to be loaded again which costed too
much time. Loading them and docking them can be done via the 'OpenEx' function,
but how to undock them without closing them? The 'Documents' collection does not
have any remove methods. Also the 'Windows' collection does not contain any
remove functionality. And the 'Parent' or 'ParentWindow' properties of a
'Window' object cannot be set.

Any help would be greatly appreciated!

Thanks,
Robert
 
M

Mark Nelson [MS]

Load time is the sum of your file access latency plus the complexity of the
Visio masters. Make sure that you are not simply experiencing network
latency for the files. Beyond that you need to determine how complicated
your masters are and if they need to be that complex. Any stencil over 400K
in size is pretty large, so those would be candidates for examination.
Unfortunately, making more efficient shapes is a difficult process and not
one that is easily explained in a message posting.
 
R

Robert Lelieveld

Thanks!

The files are not loaded from a network, so the access latency should not be
that big. However, I used the Visio XML-format to save the files. Opening them
(9 files) costed about 10 seconds. Then I changed the format to the normal Visio
format: the load time went to 5 seconds!

The shapes are not that complicated and there are only a few in each stencil
(maximal 6 shapes). Can the reason for them to load 'slow' be that there is quit
some Visual Basic code behind the shapes?

Could using a VSL file dramatically improve the load time?

The stencils (Visual Basic code) are also signed with a certificate, does this
significantly slow down loading the stencils? However, for security, they must
be signed.

To my first question: is it possible to load my stencils at startup and dock /
undock them to an opened file? I also tried using some Win32 functions
(SetParent, SetWindowLong, ShowWindow) without success.

Best regards,
Robert Lelieveld
 
H

Heidi Munson [MSFT]

Visio doesn't have a way to load files at startup except via code in COM
Add-ins (Visio 2002 or later) or an add-ons (VSL or exe, VSL has much better
performance)

Loading the VBA code does impact file load time.

You could try opening your stencil documents hidden and not docked. The
code to do this could be in either the stencil code or in a startup COM
add-in or startup VSL. Putting the code in the stencil VBA project would
only help if the user often opens and closes documents that show your
stencils in docked windows. In that case you would only take the open hit
once for the first time stencil and its code is loaded.

The documents collection is application wide. Each docked stencil window
is just a view of the document. The document is not removed from the
document collection and closed until all its views are closed or the
document is forced to close which will happen if other code calls
Document.close. All the views will be closed when Visio closes. Doing an
open on a document that is already in the documents collection does not
cause the document to be re-opened. When you open a stencil window
hidden/not docked you get a hidden MDI stencil window. This is another view
of your stencil. As long as there is at least one other view (in this case
a
hidden view) of the stencil, the stencil won't close when you close a
drawing that has a view of the stencil in a docked window.

Here is a VBA code snippet to open a stencil in a hidden MDI window:

Sub OpenStencilInHiddenMDIWindow(strStencilPath as string)

Application.Documents.OpenEx strStencilPath, visOpenRO + visOpenHidden

End Sub

-Heidi
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 
R

Robert Lelieveld

Let me rephrase that to see of I understand you correctly:

When I open and hide all of my stencils at some point in time (e.g. via a VSL at
startup using the OpenEx function you described) I can then open (docked to a
drawing window) and close these stencils again and again without actually
loading and unloading them until I also close the hidden stencils?

That's great! Precisely what I was looking for!

I will go and try that out now. Thank you for your answer.

Best regards,
Robert
 
R

Robert Lelieveld

Hello Heidi,

I have just finished implementing this and it seems to work greatly!
Visio startup time increases, but after that the load time went from 5 to 2
secondes. In total it went from 10 to 2 seconds.

Just wanted to thank you.

Best regards,
Robert
 

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