Word won't remember my library reference

J

junk

Working with Word 2003.

I have two document templates that I want to work together.

Content.DOT has just template document formatting and content - no
code at all.

Code.DOT has the code necessary to drive toolbar buttons that are
designed to manipulate the content in Content.DOT. Code.DOT has an
AutoExec() function which creates the toolbar when it loads.

I want Content.DOT to Reference the Code.DOT file. So, in Content.DOT
I open VBA and use Tools / References to add a reference to Code.DOT.

The idea is that when a document is created with Content.DOT, Code.DOT
will be loaded (after the macro security warning) and the AutoExec
will run to create the toolbar.

However, Word won't remember the Reference setting unless I add macro
code to Content.DOT, which I don't want to do.

Can I get Word to remember a library reference without adding cacro
code to my document?

Is there a better way to do this?

My goals are:
* No user install procedures - the user just opens the Content.DOT
file in a common network drive.
* No code in the Content.DOT file (so that I won't be a copy of the
code in every document created by the end-user).


I tried adding just a couple lines of code in Content.DOT, but then I
get two separate macro security warnings - One for Content.DOT and one
code Code.DOT. That may seem trivial, but if the user gets too
annoyed with the warnings, they'll just turn them off, which we don't
want.

Any ideas?

Thanks!

Lee
 
D

Doug Robbins - Word MVP on news.microsoft.com

You are under a misconception that if a template contains code, that code
will be included in every document created from the template. It is not.
What happens is if a user opens a document that was created from that
template, Word attempts to located that template in the User or Work Group
Templates folder and if it is found, a reference to it is created so that
the code in the template is available if required. If it is not found, then
the Normal.dot template is attached to the document.

The best thing for you to do is have the code in Content.dot with an autonew
and autoopen macro in that template that contain the code to display the
toolbar.

It is also best not to locate templates on a common network drive.

See the article "Distributing macros to other users" at:

http://www.word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm

Fellow MVP Jonathon West, who wrote that article, provided the following
additional reasons for following that approach:

Quote

1. If you send a document to a customer, its attached network template is
unavailable (because it is on your network, not his). The customer may
suffer very long delays (2 minutes or more) before the document finally
appears on screen. This is because Windows can take a long time before
finally deciding that no reply is going to come from the network location
that Word requests. If the attached template is on a local drive, the
existence of the template can be checked very quickly, and so the document
opens immediately even if the template is not available. Microsoft is aware
of this problem, see http://support.microsoft.com/kb/830561. Microsoft does
have an operating system fix for the problem, but if you email documents to
people outside your organisation, you cannot assume that they will have the
fix installed.

2. If the network or server goes down, quite enough of the organisation's
operations are likely to grind to a halt without unnecessarily adding
word-processing to the list by making templates unavailable for use.

3. Storing templates & add-ins locally means that users with laptops don't
need a different setup. Their templates are stored locally in just the same
way as for permanently connected desktop machines, and they can receive
updates next time they connect to the network.

4. Templates and add-ins stored locally usually load faster, reducing
startup time and improving response times for Word.

5. Templates and add-ins stored locally don't load the network with
avoidable traffic, improving performance for other applications that must
use the network.

6. Editing and updating a template at a network location is much easier if
you don't have to break everyone's lock on the file in order to replace a
template with an updated version.

7. If a user manages to mess up a template (it happens sometimes) the only
person affected is himself, and the situation can be rectified quite easily
with a re-install.

8. If templates include VBA code, I have found that occasionally the code
behaves differently if the template is open concurrently on two different
PCs. I've never been able to identify the precise circumstance that will
trigger this, but when it has occurred, I have been able to reproduce it by
having the template open on one or two machines and seeing the actions of
the macro. This kind of problem is an absolute support nightmare, so I
always ensure that my templates are always stored locally.

Unquote


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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