automated macro insertion

B

Bas Cost Budde

For conversion/standardisation purposes I would like to know how, upon
opening a document, I can have VBA add a macro to this document. Much like a
virus infection.

I am new to the Word environment but have ample programming experience, e.g.
with Access VBA. Just can't find the objects and methods I need.
 
G

Graham Mayor

Although macros can be stored in documents, it is not a terribly good idea
to do so, as the chances are that the user will simply turn off the macro.
There is no means of over-riding a user's preference, short of writing a
virus and you will not get help to do that here.

As a rule of thumb, macros should be stored in templates and if you want to
share macros they should be in global templates in a shared startup folder.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
B

Bas Cost Budde

Thanks for your reply. It does not fully address the thing I want to solve,
though.

Can the user do nothing against macros that run from a (central) template,
then?

I am dealing with an organisation here, that has made several choices beyond
my scope. The macro in question is to perform certain actions upon startup,
before loading a document. If it should be in, say, normal.dot, how can I
ensure the user that opens the document has the same functionality in his
Word? To my best understanding, this is about an organisation that does not
do centralized templates.

There will be another event where I will want to write code from code. Is it
possible at all to do so?
 
G

Graham Mayor

What is it that you are trying to do before opening a document?
The whole point of Word is that it is a single user environment that the
user can set his preferred options. If your organisation requires specific
layouts for specific documents then these should be provided in the form of
document templates which the users should be instructed and trained to use.
Whether you provide the templates centrally or individually depends on how
the system is configured.
You cannot (thankfully - as it would open the window wide to malicious code)
override the users preferences in relation to macros.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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