Template for creating Templates

N

NZ VBA Developer

O Wizards of Word! Bless me with your insight!

I thought I would post a question here before I even attempt to develop a
solution - might save me a headache or 2. ;-)

The process I'm trying to support is this: We provide templates to our
partners. Each partner gets the same set of templates, and each type of
template is identical in function for each partner - differing only in the
logo, the partner's address and a few other minor details. The code behind
each template never varies.

When we add a new partner I create a customised set of templates as follows:
I open a 'master' for each template, save it with a new file name (specific
to the partner), modify the few bits that vary (logo, address, etc.), and
then lock it down and distribute it. This works OK at the moment because I've
got a good eye for detail and I'm very familiar with each of the templates.
However, my concern is that I'll miss something or (more likely) someone will
need to take over for me at some point - either because I get hit by a bus or
my open-ended contract finally runs out or some such.

Sooo... What I'd like to do is develop an automated process for creating
partner-specific templates from the master template. Writing the code to
collect the partner details and saving the resulting document as a template
is a piece of piss, but I'm not sure how to go about the rest of it. For
instance, the current 'partner' templates use an AutoNew macro and I expect
that I'd want to use something similar for the 'master', but 2 AutoNews
obviously won't work. And then how would I go about removing the 'master'
code from the 'partner' template (or adding the 'partner' code as the case
may be)? And... and... and...

Anyway, you get the idea. Any suggestions? I guess the first question is
really: Can I use an automated template to create an automated template?

Cheers!

Kiwi Koder
 
J

Jean-Guy Marcil

NZ VBA Developer was telling us:
NZ VBA Developer nous racontait que :
O Wizards of Word! Bless me with your insight!

I thought I would post a question here before I even attempt to
develop a solution - might save me a headache or 2. ;-)

The process I'm trying to support is this: We provide templates to our
partners. Each partner gets the same set of templates, and each type
of template is identical in function for each partner - differing
only in the logo, the partner's address and a few other minor
details. The code behind each template never varies.

When we add a new partner I create a customised set of templates as
follows: I open a 'master' for each template, save it with a new file
name (specific to the partner), modify the few bits that vary (logo,
address, etc.), and then lock it down and distribute it. This works
OK at the moment because I've got a good eye for detail and I'm very
familiar with each of the templates. However, my concern is that I'll
miss something or (more likely) someone will need to take over for me
at some point - either because I get hit by a bus or my open-ended
contract finally runs out or some such.

Sooo... What I'd like to do is develop an automated process for
creating partner-specific templates from the master template. Writing
the code to collect the partner details and saving the resulting
document as a template is a piece of piss, but I'm not sure how to go
about the rest of it. For instance, the current 'partner' templates
use an AutoNew macro and I expect that I'd want to use something
similar for the 'master', but 2 AutoNews obviously won't work. And
then how would I go about removing the 'master' code from the
'partner' template (or adding the 'partner' code as the case may be)?
And... and... and...

Anyway, you get the idea. Any suggestions? I guess the first question
is really: Can I use an automated template to create an automated
template?

Yes.

What I would do is use a custom Boolean document property. I would set it to
True.

Whenever the AutoNew code runs, it would check for that property. If it is
True, it means you are working form the master. Call the sub that will
collect the info, place it where it needs to go and do all the other
changes. When you are done, set the doc property to false and save the new
template.

So, when the AutoNew runs from this secondary template thus created, the
above code will not run because the property will now be set to false.

It might work better if you use a Document_Open() Sub instead. When you want
to create secondary template, actually open the Master template, do not
create a document from it with Document_New(). Make sure that the active
document is a template, then check for the Boolean. If the document is a
template and the Boolean is True, it means you have opened the Master
itself. In case you need to maintain the actual Master, you could have an
MsgBox first that would ask the user if he is ready to create a secondary
master or not. If so, run the code, if not, just open the Master as is.

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
N

NZ VBA Developer

Bloody brilliant! Cheers Mate! I'll give it a go and let you know how I get on!
 
N

NZ VBA Developer

Jean-Guy,

Thanks again for the direction. I've now got a working 'Template Creation
Template' for one of our most common partner templates. Altho I didn't do
everything exactly as you suggested, I did build on your idea. Here's what I
came up with in the end:

I still use the AutoNew macro to run the code in the partner template, but
in the master template, it just pops a message saying that you have to open
the template to use it and then exits. I do this using a custom document
property to indicate that the template is the master, altho it's text rather
than Boolean. (I did this because I wanted to re-use the value later to aid
in the naming of a new partner template.)

I also use an AutoOpen macro (obviously, since, as stated above, you have to
open the template to use is). This macro displays a userform with options for
creating a new partner template or opening the master for editing. If you
choose 'open for editing', it just unlocks the template. However, if you
choose 'create new', it displays a userform for entering the template details.

After you have entered all the details (and they're validated), it generates
the new template, prompts for a logo (which gets formatted if it's inserted),
and then prompts to save it. I tried to force the save location to the same
location as the master, but I had a bit of a problem there. (See my later
post.)

The end result works a treat! I'm just putting a few finishing touches on it
- like a userform with instructions that requires the user to verify that
they have all the necessary info before they start - and then it's going into
production.

Thanks again for the help. I really appreciate it!

Cheers!
 
J

Jean-Guy Marcil

NZ VBA Developer was telling us:
NZ VBA Developer nous racontait que :
Jean-Guy,

Thanks again for the direction. I've now got a working 'Template
Creation Template' for one of our most common partner templates.
Altho I didn't do everything exactly as you suggested, I did build on
your idea. Here's what I came up with in the end:

I still use the AutoNew macro to run the code in the partner
template, but
in the master template, it just pops a message saying that you have
to open the template to use it and then exits. I do this using a
custom document property to indicate that the template is the master,
altho it's text rather than Boolean. (I did this because I wanted to
re-use the value later to aid in the naming of a new partner
template.)

I also use an AutoOpen macro (obviously, since, as stated above, you
have to open the template to use is). This macro displays a userform
with options for creating a new partner template or opening the
master for editing. If you choose 'open for editing', it just unlocks
the template. However, if you choose 'create new', it displays a
userform for entering the template details.

After you have entered all the details (and they're validated), it
generates the new template, prompts for a logo (which gets formatted
if it's inserted), and then prompts to save it. I tried to force the
save location to the same location as the master, but I had a bit of
a problem there. (See my later post.)

The end result works a treat! I'm just putting a few finishing
touches on it - like a userform with instructions that requires the
user to verify that they have all the necessary info before they
start - and then it's going into production.

Thanks again for the help. I really appreciate it!

Glad I could be of assistance!

--

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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