ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Turning off/on protection in a macro (https://www.excelbanter.com/excel-programming/400379-turning-off-protection-macro.html)

Lucas

Turning off/on protection in a macro
 
How do you turn off and on the protection of a workbook in a macro?

Chip Pearson

Turning off/on protection in a macro
 
Worksheets("Sheet1").Unprotect
or
Worksheets("Sheet1").Unprotect password:="whatever"

If you include the UserInterfaceOnly flag when you Protect the sheet, your
VBA code can do whatever it wants on a protected sheet. E.g.,

Worksheets("Sheet1").Protect UserInterfaceOnly:=True


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Lucas" wrote in message
...
How do you turn off and on the protection of a workbook in a macro?



Otto Moehrbach

Turning off/on protection in a macro
 
Activeworkbook.Protect

Activeworkbook.Unprotect

HTH Otto

"Lucas" wrote in message
...
How do you turn off and on the protection of a workbook in a macro?





All times are GMT +1. The time now is 08:47 AM.

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