Hiding Code

J

Jean Pereira

Using Office XP 2003.

Have created a macro to password protect a Word document but when I look in
the code I can see the password used. I am sure there must be a way to hide
the actual password in the code but don't know how?
 
G

Graham Mayor

You could protect the project with a password so no-one without the password
could view the code, but if it is only a password to protect a form the
password is easily circumvented and is only really there to prevent
accidental changes to the form.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
P

Pablo Cardellino

Hi, Graham,

Graham Mayor said:
You could protect the project with a password so no-one without the
password could view the code, but if it is only a password to protect a
form the password is easily circumvented and is only really there to
prevent accidental changes to the form.

Dou you mean the password that protects the project is easily circumvented
or the password that protects the final doc?

Regards
 
J

Jay Freedman

Pablo said:
Hi, Graham,



Dou you mean the password that protects the project is easily
circumvented or the password that protects the final doc?

Regards

It's specifically the password for "protect document for filling in forms"
that's easy to remove. The passwords for opening or editing the document and
the password for viewing the macro project are all quite strong.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
K

Karl E. Peterson

Jay said:
It's specifically the password for "protect document for filling in forms"
that's easy to remove. The passwords for opening or editing the document and
the password for viewing the macro project are all quite strong.

Ummmm, the passwords for "protecting" the project are pretty easily cracked,
actually.
 
J

Jay Freedman

Ummmm, the passwords for "protecting" the project are pretty easily cracked,
actually.

Interesting, that's the first time I've heard that. We can discuss it in a less
public setting...
 
K

Karl E. Peterson

Jay said:
Interesting, that's the first time I've heard that. We can discuss it in a less
public setting...

Sure, this is no place for details, I suppose. But believe me, it's googleable.

It's only fair to warn people that they need to compile code into a VB6 DLL if they
don't want others getting at it. This applies to Office 2000-2003, and *probably*
the old-format docs from Office 2007 but I haven't tried that.

(I've had very good luck at breaking the document-level passwords in Excel and
Access, as well. Can't remember if I ever tried it with Word. Fwiw.)
 
G

Gordon Bentley-Mix

Jean,

You could also put the password into a document variable and use that in
your code - something like this (which assumes that the password is stored
in a doc var called "MyPassword"):

ActiveDocument.Unprotect ActiveDocument.Variables("MyPassword").Value

At least the password wouldn't be right out in the open, and it would take a
bit more work for someone to find it.
--
Cheers!

Gordon Bentley-Mix
Word MVP

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 

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