macros in new blank document

J

James

I have created a word template that contains macros. When
I create a new doc from the template (dot) it does not
contain the macros, only a reference to the original dot.
Is this a bug or is there a way to change the word
settings so the new blank document contains the macros
from the template?
 
R

rlampky

You will need to use the macro organizer to copy your template macros to the
normal.dot if you want them on the blank document.

rlampky
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < James > écrivait :
In this message, < James > wrote:

|| I have created a word template that contains macros. When
|| I create a new doc from the template (dot) it does not
|| contain the macros, only a reference to the original dot.
|| Is this a bug or is there a way to change the word
|| settings so the new blank document contains the macros
|| from the template?

This is normal behaviour.
There are no settings to automatically transfer the VBA project from the
template to the documents created from that template.
However, if this is absolutely necessary, lookup the "OrganizerCopy" method
in the online VBA help.
However, this could be tricky because you will copying a project using code
that resides in the said project...

Why don't you tell us why you think you have to do that... maybe someone
will come up with a clever idea that will make things easier for you...

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

James

-----Original Message-----
Bonjour,

Dans son message, < James > écrivait :
In this message, < James > wrote:

|| I have created a word template that contains macros. When
|| I create a new doc from the template (dot) it does not
|| contain the macros, only a reference to the original dot.
|| Is this a bug or is there a way to change the word
|| settings so the new blank document contains the macros
|| from the template?

This is normal behaviour.
There are no settings to automatically transfer the VBA project from the
template to the documents created from that template.
However, if this is absolutely necessary, lookup the "OrganizerCopy" method
in the online VBA help.
However, this could be tricky because you will copying a project using code
that resides in the said project...

Why don't you tell us why you think you have to do that... maybe someone
will come up with a clever idea that will make things easier for you...

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



.

Once a new document is created it is stored in an
automated storage system for others to use. Not everyone
will have the template for the VBA to reference. Currently
I am having to create each document by hand. The doc has
user forms and buttons.

I did not have this problem with Excel 2000. When a blank
XLS is created using an XLT all of the XLT VBA code is
copied over into the new blank.

Seems odd that Word would not do the same.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < James > écrivait :
In this message, < James > wrote:

| Once a new document is created it is stored in an
| automated storage system for others to use. Not everyone
| will have the template for the VBA to reference. Currently
| I am having to create each document by hand. The doc has
| user forms and buttons.

So, just intercept the first time it is created. The first person that
creates the document must necessarily have had access to the template, so
the first time it is saved, transfer the code at the same time.

Or, why not make sure that the template is an add-in available to all users
in their start-up folder? With a bit of scripting, when users log in on the
network, the template can automatically be copied into their local machine.
Very handy also if you need to update the templates... users are not
bothered, the next time they log in, their template is automatically
updated.

| I did not have this problem with Excel 2000. When a blank
| XLS is created using an XLT all of the XLT VBA code is
| copied over into the new blank.
|
| Seems odd that Word would not do the same.

Different applications...
In Excel, once you manually create a Toolbar, it is always there (like
PowerPoint). So, unless you are careful, if you have Excel macros that are
really only applicable to one workbook, the toolbar will annoyingly be there
for all workbooks. Word is different, a toolbar is linked to a template, not
the application itself. There are advantages and inconveniences for both
systems.
One big advantage of the Word principle is that if you make changes in the
code, you just change it in one place.... you do not have to chase down all
the documents that rely on that code...Like you will in your case (if you
manage to copy the code in each document)!

Good luck!

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

James

-----Original Message-----
Bonjour,

Dans son message, < James > écrivait :
In this message, < James > wrote:

| Once a new document is created it is stored in an
| automated storage system for others to use. Not everyone
| will have the template for the VBA to reference. Currently
| I am having to create each document by hand. The doc has
| user forms and buttons.

So, just intercept the first time it is created. The first person that
creates the document must necessarily have had access to the template, so
the first time it is saved, transfer the code at the same time.

Or, why not make sure that the template is an add-in available to all users
in their start-up folder? With a bit of scripting, when users log in on the
network, the template can automatically be copied into their local machine.
Very handy also if you need to update the templates... users are not
bothered, the next time they log in, their template is automatically
updated.

| I did not have this problem with Excel 2000. When a blank
| XLS is created using an XLT all of the XLT VBA code is
| copied over into the new blank.
|
| Seems odd that Word would not do the same.

Different applications...
In Excel, once you manually create a Toolbar, it is always there (like
PowerPoint). So, unless you are careful, if you have Excel macros that are
really only applicable to one workbook, the toolbar will annoyingly be there
for all workbooks. Word is different, a toolbar is linked to a template, not
the application itself. There are advantages and inconveniences for both
systems.
One big advantage of the Word principle is that if you make changes in the
code, you just change it in one place.... you do not have to chase down all
the documents that rely on that code...Like you will in your case (if you
manage to copy the code in each document)!

Good luck!

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



.
You are correct. The problem I have with doing it that way
is that our company is spread out over 70+ networks
worldwide. Different departments and business units have
different authentication points.

The document, once created, is a living document. When a
new revision is required it is created from the latest
version of the template.

I must be able to have others in different areas of our
organization work on the documents without having to worry
about suppling the template or any scripting.

I am looking into the earlier suggestion of using
OrganizerCopy though I have not found any documentation
that explains how to copy VBA code from one doc to another.

Best Regards,
James
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < James > écrivait :
In this message, < James > wrote:

| You are correct. The problem I have with doing it that way
| is that our company is spread out over 70+ networks
| worldwide. Different departments and business units have
| different authentication points.
|
| The document, once created, is a living document. When a
| new revision is required it is created from the latest
| version of the template.
|
| I must be able to have others in different areas of our
| organization work on the documents without having to worry
| about suppling the template or any scripting.
|
| I am looking into the earlier suggestion of using
| OrganizerCopy though I have not found any documentation
| that explains how to copy VBA code from one doc to another.
|

Look it up in the VBA help, there are some simple examples involving
styles... so you will have to adapt them.
Alternatively, a bit of Googling from
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&group=microsoft.public.word.vba
will yields lots of hits.

You may want to look into this as well:

ActiveDocument.VBProject.VBComponents.Export
ActiveDocument.VBProject.VBComponents.Import

Basically you export the modules as *.bas files where ever you want, then
import them in the destination document.
Then you can delete the *.bas files..

Good luck!

--
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