Question

I have a VBA macro which runs in Word 2003. It is one module and the code attached to a userform, and it goes to about 30 client sites. When I first rolled this out I sent someone round to each site to place a .dot template in the Word Startup folder of each of 30 boxes, which then makes the macro appear as a button on the toolbar for each user.

All the users are internet connected.

The location of the .dot template varies from machine to machine, so "installers" would be out of play I presume?

I am anticipating that the macro made need to change from time to time. Is there any way I could get the user to press a button to get the macro to update itself?

Whether its push button or auto run checking for update, I would presumably need to know how to determine where the macro is running from (path) without a document necessarily having been saved, and how to find path to the Startup folder tools>options>file locations but programatically .

Was it helpful?

Solution

This can be done.

  1. create 2 .dot files, loader.dot (checks for updates) and worker.dot (the main macro you are using and want to be able to update automatically).

  2. the first loader.dot should go into C:\Program Files\Microsoft Office\OFFICE11\STARTUP

This is a trusted location and the macro will be loaded into any Word document. Use an AutoExec() subroutine to ensure it runs whenever a word doc is loaded.

worker.dot can go in any fixed installation location e.g. C:\yourapp\worker.dot

The logic in loader.dot is remove any reference to worker.dot (I had to enable trust of VBA model in macro security settings) check for an update using an http call, if new version available download it overwriting worker.dot, then add reference from file specifying worker.dot

OTHER TIPS

I'm not sure that the user-presses-a-button model is ideal.

I'd look into building a "loader" template. Its job would be to run at startup and look for updates to the template/macro you already have and download/install/whatever such files when they change. Then load whatever's installed locally for use.

You should also think about whether it's a problem if an update is available but someone doesn't use it (perhaps they started Word before the change was uploaded, or they're offline). Also, do you need to know what version people are using? Have your loader report back, via HTTP, email or some other method (Twitter?)

Any such loader needs to either very stable (otherwise you just replace chasing around replacing the target template with chasing around replacing the loader) or able to update itself when necessary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top