VBA code in template disappears

  • Thread starter got questions via OfficeKB.com
  • Start date
G

got questions via OfficeKB.com

I would really like to understand how Word 2000-2003 handles vba and macro
customizations.

Can anyone explain those circumstances that vba code in a 'new macros module'
would disappear or be stripped out? In the 2003 software - will a security
setting of 'high' automatically delete or strip out the code? Also - the
default save on the master templates is to a .doc. I have found that the
customizations are carried over to the .doc with a save or save as, however,
sometimes the code disappears or custom toolbars disappear but the code is
still there.

The Word templates I create are stored on one of the company's servers.
Custom tabs have been added to all employees word software and they can
access the templates by selecting FILE-NEW and clicking on the tab and then
the file. Any vba customization is stored in the master template on the
server and not in 'normal'. Unless altered by the employee, Word security
settings are set to 'high'.

Sometimes, when an employee emails a .doc (produced off the master template)
to another employee, upon opening, the code is there but toolbars are gone
and not in the dropdown list. Other times, they receive a security message
to disable or enable the macros (they have been instructed to select enable)
and the customizations are enabled, however, when this file is emailed back
to the sending employee, they are gone!

Can anyone please clarify what is happening so I can correct so they are
consistent and reliable?

Please send help!
 
K

kozaw

I would really like to understand how Word 2000-2003 handles vba and macro
customizations.

Can anyone explain those circumstances that vba code in a 'new macros module'
would disappear or be stripped out? In the 2003 software - will a security
setting of 'high' automatically delete or strip out the code? Also - the
default save on the master templates is to a .doc. I have found that the
customizations are carried over to the .doc with a save or save as, however,
sometimes the code disappears or custom toolbars disappear but the code is
still there.

The Word templates I create are stored on one of the company's servers.
Custom tabs have been added to all employees word software and they can
access the templates by selecting FILE-NEW and clicking on the tab and then
the file. Any vba customization is stored in the master template on the
server and not in 'normal'. Unless altered by the employee, Word security
settings are set to 'high'.

Sometimes, when an employee emails a .doc (produced off the master template)
to another employee, upon opening, the code is there but toolbars are gone
and not in the dropdown list. Other times, they receive a security message
to disable or enable the macros (they have been instructed to select enable)
and the customizations are enabled, however, when this file is emailed back
to the sending employee, they are gone!

Can anyone please clarify what is happening so I can correct so they are
consistent and reliable?

Please send help!

I thinking the following..

1. A procedure on Normal Template of each PCs, that will attached the
template (A) as global-addin.
with following condition ...
if Not activedocument.name = NameOfTemplate(A) AND
activedocument.attachedtemplate.name <> NameOfTemplate(A)

2. Put an unique template (A) (codes + customisations) on server, with
a macrobutton on 1st page. Set target to Procedure name from step (1)
to that Macrobutton.

3. Like you say every document (produced off Template(A)) will have
that macrobutton, thus easily reattached to Template(A) in case it's
codes & customisation are lost.
Evenif you have lost connection with Template(A), clicking Macrobutton
will reattach Template(A) to activedocument as global template.

Like I wrote in other thread, you should be set context of toolbars as
temporary. so they can't exist whenever employee exist from WORD in
each PC, and so prevent from annoying duplicated toolbars.
Brgds,
Ko Zaw
 
C

Cindy M.

Hi Got,
Can anyone explain those circumstances that vba code in a 'new macros module'
would disappear or be stripped out?
This will happen if changes to the Normal.dot template were not saved when
Word was exiting, and were not saved explicitly before that point. This could
happen, for example, if you have an Add-in that's telling Word there's nothing
to save in Normal.dot - not uncommon in order to avoid prompts appearing.

Other than that, it could happen if Word can for some reason no longer locate
Normal.dot (it was renamed, for example). Or if the folder in which it's
located where moved or deleted so that Word can no longer find it. Or if the
user hasn't permissions to save to that folder location.

If this is happening to macros that have been in Normal.dot for more than one
Word session, the only other possibility is macro code that's accessing and
deleting code in the Normal.dot.
In the 2003 software - will a security
setting of 'high' automatically delete or strip out the code?
No. The security settings can only prevent code from loading into the VBA
editor and running. But "High" shouldn't be doing that for Normal.dot unless
"Trust all installed add-ins and templates" is deactivated.
Also - the
default save on the master templates is to a .doc. I have found that the
customizations are carried over to the .doc with a save or save as, however,
sometimes the code disappears or custom toolbars disappear but the code is
still there.
If you have a *.dot file and you use Documents.Add on it, or the user goes
over File/New and selects the template, the result will automatically save to
*.doc in the Document file format. In this case, macros will NOT transfer to
the *.doc files. Only through the link to the *.dot file (Tools/Templates and
Add-ins, top box) are macros and toolbars available to "child" documents of a
template.

If the macros are in the "documents" you're creating, that means you're
OPENING the *.dot and just giving it a name of *.doc. In reality, these files
are still templates. *.dot files were NOT designed to be used in this manner.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

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