Adding macros to a document created from a template

C

Craig Miles

Hi,

I have a template on a web server. When a particular request comes the
template is opened and one of
it's macros is called. This macro creates a new document populating bits and
pieces from the database etc.
This new document is then downloaded to the client machine. The original
template does not exist on the client.

My problem is that when the user downloads and opens the new document it
needs to have some code in it to
create a custom toolbar and override the save to put information back to the
database.

Is there a way when the new document is created on the server (by the
template macro) to insert macros into the new document as well?

Thanks,
Craig Miles
 
P

Peter Hewett

Hi Craig Miles

The major problem with this is that unless you're running on a corporate IT network where
you can control the configuration of the users PC you're in for problems. If you haven't
already you need to consider the version of Word that's in use and the macro security
levels. To run you code at all macro security has to be set to either "medium" or "high".
If you use "high" you *must* sign the project (which creates a new set of problems!).
Also, if you want to actually modify the code in Word XP onwards you also require the
"Trust access to Visual Basic Project" to be enabled as well.

You have two options which are the reverse of each other, but you end up with the same
result. You can create a template and then copy the appropriate macros to the new
document. Or you can create a document and use that to create new documents. Using the
latter approach the macros will be automatically propagated to the new document. You can
then decide where you want to delete the redundant code or not. Obviously this is going
to result in larger documents as each document carries the macro code around with it.

HTH + Cheers - Peter
 

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