Rawb0:
Interesting suggestion, deploying code from the web. Not sure how to do that; I've been using another way to distribute code: via the stencil.
It’s a technique I learned here a few years back, and I’ve been using it ever since. The idea is to put your code into a stencil, then distribute the stencil. When it’s time for a code update, I just give everyone a new stencil and tell them to throw away the old one. Not as elegant as downloading on demand from the web, but it does work. I
posted the details here a few years ago about how I go about it, and I’ve found the approach to be very flexible. It might be a good Plan B for you if you can’t find a way to download your code.
Now that you got me thinking about it, perhaps you
could use a stencil-based solution to download your code. Put a small VBA routine in the stencil (as you suggested) that triggers on the document open event. Whenever you open the stencil, it downloads your code from some .txt document you have on the web somewhere, then stores it in ThisDocument or some other module in the Visio drawing.
I did something similar with a Visio VBA macro I wrote that programmatically creates and populates an Excel spreadsheet from within a Visio drawing, then copies a bunch of Excel VBA code from the stencil into the spreadsheet. Sounds simple, but it has a lot of odd twists and turns. Details of the self-coding technique came from a
pretty exhaustive post on the topic from Chip Pearson. One caveat: For it to work you need to have the users check an obscure option in the Trust Center, “Trust Access to the Visual Basic Project”. That could be a security concern. Worse yet, in some environments (like my current one) the Powers That Be have disabled all programmatic access to the VB project, which stops you from copying any code at all. That could be a show-stopper for your plan to download code; but distributing code via the stencil would still work regardless.
Of course now that you got me thinking about a possible viable solution for downloading from the web, I’ll have to try it. In my copious free time...
- Ken