Lilbit was telling us:
Lilbit nous racontait que :
Hi Jean -- On July 15th, I was trying to find a way to hide my
password in the spell check macro (Macro Font was subject). I was
going to try to make it invisible, or possibly code it a way that the
user couldn't understand, but VBA would. You suggested I use
document variables.
Yes, I suggested document variables as a way to store the password in the
document, not on the page itself. The code I suggested was:
Dim GetPassword As String
ActiveDocument.Variables("myvar").Value = "MyPassword"
GetPassword = ActiveDocument.Variables("myvar").Value
Dim GetPassword As String
creates a variable.
ActiveDocument.Variables("myvar").Value = "MyPassword"
creates the document variable to store the password in the document
binary code
GetPassword = ActiveDocument.Variables("myvar").Value
retrieves the password into the variable created above.
Now you can use this variable.
What I do not understand is that if you control the password value you do
not need to store it anywhere, just use it in the code directly.
It is still not clear what you want to do with the password in your code. If
it is just a question of un protecting/reprotecting a form, then you do not
need document variables:
ActiveDocument.Unprotect "MyPassword"
'Do some stuff
ActiveDocument.Protect wdAllowOnlyFormFields, True, "MyPassword"
So why hide the password anywhere when all you need to do is use it directly
in the code?
The only time I have done something like hiding a password in a document
variable was when I had created my own system of setting a password,. that
meant that my code did not "know" the password that was created by the user,
instead, it called the document variable that the password setting routines
used.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org