Protecting VBA & Macros

J

Jim

I have an Access 2000 db linked to various Word 2000
templates with merge fields and logic fields. I am
learning/working toward automating the merge process, so
that upon the click of a button in Access, the
appropriate Word template opens, merges into a new doc,
the template closes (leaving the new doc open), and the
user is left with a new (merged) doc, but the user cannot
access the merge fields, logic fields, macros, or VBA
associated with the document. I have cleared most of
these hurdles (other than closing the template, after
merger-I think I'll need to do this in VBA-but I
digress. My question here is as follows: How do I
protect the VBA and macros associated with the Word
documents? In other words, how do I keep users from
accessing this information in the templates and/or merged
documents?

I am amazed at how generous the contributors to these
forums are with their time and knowledge. Sort of a
throw back to the barn-raising days. Thank you in
advance.

Jim
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, notre ami < Jim > nous laissait savoir que :
In this message, our friend < Jim > informed us that:


|| digress. My question here is as follows: How do I
|| protect the VBA and macros associated with the Word
|| documents? In other words, how do I keep users from
|| accessing this information in the templates and/or merged
|| documents?
||

From the project properties (VBA Window) you can password-protect your
project.
Make sure you keep the password in a separate place or a few years from now
when you are asked to modify something you will be stumped!

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

Jim

Thank you. I have a follow-up question. I followed your
suggestion and for many of the documents, it works
great. However, for some of my documents, when I click
on project properties, I get an error message "project
locked, project is unviewable". I did previously attempt
to build security into one of my documents and then
aborted those efforts. I thought that this might be the
source of the problem and so I deleted that document and
replaced it with a back-up copy, but the problem persists
with that document and others. I should also add that I
have not yet added any VBA to most of these documents-if
that makes any difference. Is there anything I can do
remedy this problem and get to the protection tab?

Thanks again.

Jim
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, notre ami < Jim > nous laissait savoir que :
In this message, our friend < Jim > informed us that:


|| Thank you. I have a follow-up question. I followed your
|| suggestion and for many of the documents, it works
|| great. However, for some of my documents, when I click
|| on project properties, I get an error message "project
|| locked, project is unviewable". I did previously attempt
|| to build security into one of my documents and then
|| aborted those efforts. I thought that this might be the
|| source of the problem and so I deleted that document and
|| replaced it with a back-up copy, but the problem persists
|| with that document and others. I should also add that I
|| have not yet added any VBA to most of these documents-if
|| that makes any difference. Is there anything I can do
|| remedy this problem and get to the protection tab?

Sorry, I don't follow... Why would you want to protect a VBA project that
does not contain any VBA?
And when you use the term "document"... do you mean you are attempting to
get to the document's tempate's code from a document created form its
template (*.dot), or do you have code in actual documents (*.doc)?

||
|| Thanks again.
||
|| Jim
||| -----Original Message-----
||| Bonjour,
|||
||| Dans son message, notre ami < Jim > nous laissait savoir que :
||| In this message, our friend < Jim > informed us that:
|||
|||
||||| digress. My question here is as follows: How do I
||||| protect the VBA and macros associated with the Word
||||| documents? In other words, how do I keep users from
||||| accessing this information in the templates and/or merged
||||| documents?
|||||
|||
||| From the project properties (VBA Window) you can password-protect
||| your project.
||| Make sure you keep the password in a separate place or a few years
||| from now when you are asked to modify something you will be stumped!
|||
||| --
||| Salut!
||| _______________________________________
||| Jean-Guy Marcil - Word MVP
||| (e-mail address removed)
||| Word MVP site: http://www.word.mvps.org
|||
|||
|||
||| .

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

Guest

Note: Oddly enough, after 4 or 5 hours of struggling with
the below referenced issue yesterday, this morning, after
having written the reply set out below, the problem seems
to have disappeared as quickly as it came on. I don't
know if this is a result of something I did while I was
half-asleep last night or if my computer just needed to
clear some junk out. (I did turn it off and on during my
struggles, but maybe for not long enough a period.)
Anyway, I will post my reply below anyway, in case the
problem returns and/or maybe it will help someone
somehow. Thank you again. . . . .

I believe I created some confusion by using the wrong
terminology. I don't think I'm working with any *.dot
files and so I should not have used the term "template".
Rather, I am working with 40+ Word 2000 documents (a.k.a.
main merge documents?), linked to an Access 2000 db, that
contain merge fields and Word logic fields. The
documents at issue will be these "main merge documents"
and the resulting merged documents, all of which, as I
understand it, are *.doc files. The "main merge
documents" are opened via corresponding command button in
Access 2000. I wish to place VBA in each of the "main
merge documents" that will cause them to open, merge into
a new document, and then close, leaving only the new
document open. (I have received help with this issue
previously.) As I understand it, the code associated
with each of the "main merge documents" will also be
associated with the new merged documents. I want to keep
users from accessing the VBA for any "main merge" or
merged documents. I have experimented with a few of
the "main merge documents", adding appropriate VBA and
then attempting to add protection via the VB editor, by
right clicking on the project and then clicking
on "project properties". With respect to most of
the "main merge documents" have tried this with, I get
the message "Project protected. Project is unviewable".
The reason the documents did not have any VBA associated
with them was because I wanted to make sure adding the
code and protection worked with one documents before
trying it on all of them.
 
J

Jim

As I feared the problem seemed to return today. However,
after working at it, I learned that I can access
the "project properties" for the main merge Word
documents so long as I do the following: Open one
document at a time from Access, using the appropriate
command button, but do not open a 2d document; do not
open the documents via Word or by double clicking on
their icons; after completing work on one document, it is
necessary to close not just the document, but also Word,
before opening the next document. Sounds crazy and no
doubt I messed something along the way, but this is the
only solution I have found. I wonder if my problem stems
from derving virtually all of the documents from a single
document via "Save As". Oh well.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, notre ami < (e-mail address removed) > nous
laissait savoir que :
In this message, our friend < (e-mail address removed) > informed
us that:

<snip>

|| I believe I created some confusion by using the wrong
|| terminology. I don't think I'm working with any *.dot
|| files and so I should not have used the term "template".
|| Rather, I am working with 40+ Word 2000 documents (a.k.a.
|| main merge documents?), linked to an Access 2000 db, that
|| contain merge fields and Word logic fields. The
|| documents at issue will be these "main merge documents"
|| and the resulting merged documents, all of which, as I
|| understand it, are *.doc files. The "main merge
|| documents" are opened via corresponding command button in
|| Access 2000. I wish to place VBA in each of the "main
|| merge documents" that will cause them to open, merge into
|| a new document, and then close, leaving only the new
|| document open. (I have received help with this issue
|| previously.) As I understand it, the code associated
|| with each of the "main merge documents" will also be
|| associated with the new merged documents. I want to keep

<snip>

I think we need to clarify this issue:

The only way the merged documents will be linked to ant VBA code is if you
start from a dot template.

Here are 3 scenarios to illustrate:
1)
You have Test.dot that is a main merge document with VBA code.
You open Test.dot.
You merge to a new document.
Save the result as Test Merged.doc.
Close Word.
Open Test Merged.doc.
No VBA code and no link to Test.dot.

2)
You have Test.dot that is a main merge document with VBA code.
You create a document from Test.dot.
Save this document as Main Test Merge.doc (You do not have to save it, but
it makes it easier to illustrate).
You merge to a new document from Main Test Merge.doc.
Save the result as Test Merged from doc from dot.doc.
Close Word.
Open Main Test Merge.doc.
There is VBA code linked to Test.dot.
Open Test Merged from doc from dot.doc.
There is VBA code linked to Test.dot.

3)
You have Test doc.doc that is a main merge document with VBA code.
You open Test doc.doc.
You merge to a new document.
Save the result as Test Merged from doc.doc.
Close Word.
Open Test Merged from doc.doc.
No VBA code and no link to Test doc.dot.

I have a feeling that you are using the third scenario, in which case you do
not have to worry about VBA being visible to users because there will not be
any VBA in the merged result.

Does that help?

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

Guest

You are correct: The third scenario applies to my
documents and I there is no VBA code assoxiated with the
newly created (merged) document. Thank you again.

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

Dans son message, notre ami <
(e-mail address removed) > nous
laissait savoir que :
In this message, our friend <
(e-mail address removed) > informed
 

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