VBA and Security Certificates

R

Roderick O'Regan

I don't know whether this is relevant here but would like to know if
someone has had experience of the following. Failing that, a pointer
to an appropriate newsgroup could be helpful:

I have signed macros with a security certificate and time stamped them
also. My client has now asked me if it is possible to trap the button
which says "Disable Macros" in the security dialog box and prevents
the document from opening at all rather than opening with disable
macros.

In other word "Accept the macros for these templates or nothing will
open".

My initial feeling is that it cannot be done. But I'd like some
experienced views on this, if possible.

Roderick
 
W

Warrio

Hi Roderick,

everything is possible if you spend enough time on it...

but I didn't get what you really want to do...

- Do you want to skip the message box asking to enable or disable the
macros inside your file?
you must have been able to do it if you are using a trusted
certificate...

- and which templates are talking about?

- what would happen (in the desired version) when the client tries to open
your file?

PS: I'll go on wend soon, but I'll look for your answer on Monday!
 
R

Roderick O'Regan

Hi Warrio.

Thanks for the reply.

As I mentioned, I have developed some templates with VBA modules
within each of them. They are **not** based on the Normal template

I have bought a security certificate from Thawte to allow me to secure
VBA code.

It all works perfectly except that my client has asked for an addition
whereby if one of their users runs the template and the dialog box
appears asking them whether they trust the template or not, then if
the user selects the "Diable Macros" button or the Close (X) button it
shuts the document down completely rather than opening it without the
macros.

In other words, my client wants to say to their users "If you don't
accept the macros you will not even get the document"

I suppose it is really trapping the user's reply before the macros are
run.

Does this help a little more, now?

Roderick
 
W

Warrio

Much clearer now!

First, if you have bought the certificate, it was to do not have this
message box asking whether to enable or disable the macros. It's purpose
that it certify that the code inside is safe and can be trusted.

So all the users who would use the document should open the document whitout
having to answer any question, unless you haven't set your certificate
correctly.

But now if your client wants to separate users that have clicked on yes from
those who have clicked on no, you can do nothing (you cannot run a code that
will disable the opening of the document and nothing else because the user
doesn't allow you to run any code!! logic).


so for that you must use a trick and you have three solutions:

1. is to create a document that will open the file that you are interest in.
just write in the the Open Event of your Document
Application.Documents.Open "" 'Your document full path
ThisDocument.Close False 'Close the document

because this document has some code in it, it will ask the question :"Enable
or disable macros"....
if the user accepts, it will do what you want, if not, he will see only a
blank document (that you can set to ReadOnly to he cannot modify it)
that's a solution, a bit weird, but works..

2. the best solution is to everything by code!
in your document that must run without having MSWord asking to enable or
disable your code, because now you have a trusted certificate.
at the opening of the document, You will ask with a message box your client
question
if the user answers yes, you will do something, if not, you'll do something
else.

the advantage of this solution is that it allows you to run your code in any
case.

3. Set a password to your document like the company name so all the users
can remember it...
 
R

Roderick O'Regan

Thanks for the reply, Warrio.

Once I get my head around the three solutions I'll put them in a way
that my client will understand.

Knowing him he might decide it's not worth it and say to his users "If
you don't trust the source you'll get a blank document without any
functionality (the normal condition) but don't shout at me if nothing
works!"

Roderick
 

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