View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
nick nick is offline
external usenet poster
 
Posts: 192
Default Alternative to hardcoded password ?

Thanks. Dave's suggestion to use the dialog in conjunction with checking the
password in the BeforeSave event should allow this to work. I tested it
here, time will tell how well it works in the field.

Appreciate the suggestions.



"Peter T" wrote:

In addition to Dave's suggestion about providing an interface, assuming VBA
protection is not the issue maybe in the before save event you could attempt
to test protection. If it fails with your password cancel the save with
appropriate message to your user.

Regards,
Peter T

"Nick" wrote in message
...
I have a password-protected worksheet in which users enter input into
unlocked cells. After clicking a button, VBA updates protected cells.

To do this, the following statement appears in the Workbook_open proc:

ThisWorkbook.Worksheets("User").Protect "mypw", True, True, True, True

The worksheet is already saved with the sheet protected. I use this
statement for the final "True" argument, to protect the UserInterfaceOnly

but
permit VBA to update the worksheet.

With Excel 2002, I need to hardcode the password in the VBA. (Excel 97,
2000 did not require the password in VBA.)

I would like to give the worksheet password to an administrative user to
change certain locked cells before the workbook is distributed to the

users.
But if the administrative user inadvertantly changes the worksheet

password,
the VBA no longer can update the worksheet.

Any alternatives to allowing VBA to update the worksheet without

hardcoding
the password?