View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default declaring public variable value

Hi Damon,

Try:

In a standard module try:


Public PWORD As String


Sub SetIt()
PWORD = "MyPassword"
End Sub

Sub ReadIt()
MsgBox PWORD
End Sub

---
Regards,
Norman



"Damon" wrote in message
...
Hi all,

I have a public variable that is currently declared as string at the top
module 1

How and where should I set/define the variable value so that it is the
same
and available to any macro/procedure in the project/wookbook?

currently trying

set Pwd = "owntext" ' Pwd is the public variable

The value for Pwd is the password for locking/unlocking sheets so I do not
want to have to set it more than once if possible..

On a kind of related note is there a way to stop people viewing the
macros?

I can protect pages, I can prevent the original file being over written, I
can even prevent anybody other than me from saving the file at all but
this
is almost pointless if the user can view & edit macros