ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Locking and unlocking a workbook (https://www.excelbanter.com/excel-programming/301998-locking-unlocking-workbook.html)

Nigel Bennett

Locking and unlocking a workbook
 
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

Tom Ogilvy

Locking and unlocking a workbook
 
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
--
Regards,
Tom Ogilvy



"Nigel Bennett" wrote in message
...
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





All times are GMT +1. The time now is 06:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com