View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default Macro containing password?

Dim bProtected As Boolean
Const PW as string = "PWord"

If Sheet1.ProtectContents Then
Sheet1.Unprotect PW
bProtected = True
End If

'do stuff here

If bProtected Then Sheet1.Protect PW


Tim.


"kildevil" wrote in message
...

Is it possible to place a password on the protection feature of a
worksheet and program a macro to run without stopping to request the
password?

I share workbooks with others and protect cells to prevent
reconfiguration. Several workbooks contain macros. Usually the
first
step in the macro is to remove the protection from the worksheet
before
manipulating the data. The last step is to return the protection to
the
worksheet. I have problems with others manually removing the
protection
and doing "their thing" to the workbook. If I place a password on
the
protection, the macro stops and asks for the password, so I normally
place the protection on without a password. It stops the casual
user,
but not those intent on modifying my spreadsheet. I want to
continue
sharing the workbooks, so I live with the "help".

Can I prevent this help and still run my macros?

Thank you for any help.


--
kildevil
------------------------------------------------------------------------
kildevil's Profile:
http://www.excelforum.com/member.php...fo&userid=6319
View this thread:
http://www.excelforum.com/showthread...hreadid=270709