Add code straight into the Document_Open in word doc?

J

johnnybhoy

Hi Folks,

Is it possible to add code Programmatically into the Document_Open event of
a document only using an attached template?

The document is going to be created based on a standard tempate and attached
to the template. Problem is that if the templates are moved then this will
not work. I wan't to have the Document check the registry for a flag when
it opens, if the flag is present then attach the template based on the
location provided by the flag. Make sense?

Cheers

John
 
M

martinique

Yes it's technically feasible to write one code module from another: explore
the nether regions of the object model and you'll find the VBE projects
collection: you can manipulate this directly from code.

But it doesn't sound like a feasible solution to your problem. First, there
are serious security issues. For obvious reasons, network setups are
configured explicitly to prevent this sort of activity. But second, what's
the actual issue? Your document is attached to the template at creation (by
definition). After that, why does it need the template? -- either, to
restore the styles when the document is re-opened, or to provide
functionality. Either way, that puts the onus on the user not to delete the
template: if the user kills the template, you have to assume it's because
they wanted to, in which case they'll be rightly annoyed if your document
retrieves it. An anyway, if the template gets moved from its original
location, then the registry location will surely be wrong also?
 
J

johnnybhoy

Well there are a lot of things involved in this one and the main reasons are
to restore options to their original state, provide functionallity not
normally available in word and capture application level events (Close and
such) with a Class module I've written which must be stored in words
templates dir.

The registry isn't a serious issue because there are a series of checks put
in place by a pre initiated wizard that will find the template and set the
registry. The users will not have write access to the template and will
only ever use the template when they initialize the wizard. All very
complex! :-(

Cheers
 
J

johnnybhoy

thanks for the advice dude! I will be looking at your suggestions very soon

Cheers

John
 

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