Locking and unlocking a workbook

N

Nigel Bennett

I have a spreadshhet called Finance that I want to lock
and unlock using a button, what is the syntac for locking
and unlocking a workbook using code

Thanks

Nigel
 
T

Tom Ogilvy

workbooks("Myworkbook.xls").Protect Password:="ABCD"

workbooks("Myworkbook.xls").Worksheets(1).Protect Password:="ABCD"

replace Protect with Unprotect to unlock them.

See help for options that can be used with the commands.

You can also protect at the file level - see the workbook SAVEAS command for
options.

Workbooks("Myworkbook.xls").SaveAs
 

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