Code Distribution

Started by bhcohen, February 06, 2009, 06:54:50 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

bhcohen

What is the best way to distribute the VB code I have developed inside of Visio?

As I have probably overdesigned things, I have a lot of class modules, forms etc.. that are sitting inside of a Visio document.  If I want to distribute these to Visio users, is there some way to do this that doesn't involve individually exporting each file and re-importing them into a separate document?

Thanks,
   Bruce

vojo

I have used a template...ensures code goes with workspace and such.

workspace may be better...but never used it

Visio Guy

If you put the VBA code into stencils, then each document won't be laden with code.

Also, with code-in-stencil, you have a single point for updates to the code, instead of every single document ever created.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vojo

this has been real confusing to me, but I dont think you can actually put code in stencils.
Remember, I asked about this a couple times 1 year ago (wanted to put VBA in stencisl so
could ship stencil around to others...they would enable with their security settings).

After looking on the web and getting a posting back suggested that if you could actually manage to get
code in a stencil, the code would have to discover and build up the environment on every use
(where files are saved, what drawings are in current file, etc).

So I resigned myself to templates.

If I misunderstood all the info, sure would like to see an example of VBA in a portable stencil.

Visio Guy

Well, I think it depends on what the code is doing.

If the code is listening to events, customizing the UI (menus, etc) and Taking Over, then you are right, the stencil deliver might be a bit cumbersome. I can see a situation where stencil code would have to do a bunch of analysis to figure out which of all the open drawings it was supposed to control and customize.

But if the code is just helping shapes out--for instance shapes calling VBA procedures via double-click or right-mouse actions (using the CALLTHIS ShapeSheet function), then this type of delivery makes a lot more sense.

There is a situation where people *require* the stencil to open with the drawing. You can do this somewhat by adding references to the stencil file, but I have only experienced crashes with this. Maybe it has improved since I tried it, but this might have been another caveat.

With code-in-stencil, you run the risk of having shapes that "do nothing" if the stencil isn't open. Ie: if the code can't be found because the stencil is closed, then the shapes don't have access to advanced custom functionality. For some solutions this might not be acceptable. But for many, smaller, rapidly developed solutions this is ok.
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

vojo

I am of the latter case (shape helpers).

The problem I was told was that the VBA would have to build the framework of the drawing the stencil is being used in.  it would have discover a bunch of settings and configuration.  This would have be triggered off some invocation to get this framework in place before the shape helper is called (as part of the call or some earlier call to initialize a bunch of stuff).

I will try to dig up the post here from like september 08 or so.   If I recall correctly, it was like 50-100 lines just to get to the point where actual function could be launched.   

If I misunderstood....an example would be appreciated!!!!

aledlund

you can very definitely put code in stencils, I've done a lot of it (often as code only). Like Chris was saying it has the advantage of being to able to update a solution by just updating a stencil. Some of the code you need in the document is the ability to check if the stencil has been loaded. You can also take take the steps to have the code in the stencil 'referencable' by the template. I posted some of this when Vojo was looking for information on his project.
Looking back on it I probably should have taken Graham Widemans approach at making a vsl out of it.
al