Spawned document from Template (Dot) loses macros

J

Joshua

Here is a screenshot I am working on:
http://www.jkfweb.com/files/Example.JPG

The file is a .Dot template file. It works great normally when a user opens
from the Template and fills in the appropriate information.

I have a few users who want to open the file, fill in there name and the
Company Name and other appropriate fields and then save that as a .dot file.
This would allow them to not have to re-type and look up the information
everytime.

The problem is the macros are apparently not being copied when word spawns
document1 from the template. I'm assuming this is normal word behavior, but
haven't been able to find a solution on word.mvps.org and a quick search in
newsgroups didn't find the solution either.

Any ideas how to get the macros to go into the newly spawned document as
they are used to create new rows, do some error correction, and formatting of
fields.

Thanks in advance for any help.
 
S

Shauna Kelly

Hi Joshua

The way Word is designed to work is that you put your code in a template,
and users create a new document by doing File > New and choosing your
template. The template makes all your code available to the document. So
when a user saves the document, and re-opens, all those tools (command bars,
macros, keyboard shortcuts and AutoTexts) are once again available to the
document.

For more information, see
What is the relationship between a Microsoft Word document and its template?
http://www.ShaunaKelly.com/word/templaterelations/index.html

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
N

NZ VBA Developer

Shauna,

I think you missed something here. I think the process that Joshua is trying
to describe is something like this:

The user creates a new document from a template containing some code, fills
in a few of the fields in the userform and saves the resulting document as a
_template_. The user then expects to be able to create a document from this
'new' template and have the code from the original template (with the
partially completed userform) appear automatically.

The question is, why doesn't this new template contain the code that's in
the original template?

The information you've provided is the right answer, but to the wrong
question. ;-)

Joshua, the reason this new template doesn't contain any code is because the
code is - and always will be - in the original template, not in the resulting
document. So even though you're saving the document as a template, it's not
enough; you'll have to find another way.

I've been working on something similar trying to provide functionality to
allow users to rerun a macro that I think just might fit the bill. Send me an
email (on my profile) if your interested.
 
J

Joshua

NZ VBA Developer and Shauna,

I appreciate feedback from both of you. NZ VBA is correct with his
assessment of the situation.

I've decided the easiest way to handle the situation is to provide the form
in .dot format and .doc format for those who want to keep a modified version
and just change certain fields.

The .doc will not lose the macros and they can save as many copies as they
like.

Thanks again!

Joshua
 

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