ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   workbook Protection Toggle Macro (https://www.excelbanter.com/excel-discussion-misc-queries/43024-workbook-protection-toggle-macro.html)

Just Learning

workbook Protection Toggle Macro
 
Does anyone have a macro for toggling workbook protection?

E.g., run the macro and it unprotects the workbook if it's in a protected
state and vice versa.

Thanks for any help given!

Don Guillett

try

Sub protectunprotecttoggle()
If ActiveWorkbook.ProtectStructure = True Then
ActiveWorkbook.Unprotect Password = "d"
Else
ActiveWorkbook.Protect structu=True, Windows:=False, Password:="d"
End If
End Sub

--
Don Guillett
SalesAid Software

"Just Learning" wrote in message
...
Does anyone have a macro for toggling workbook protection?

E.g., run the macro and it unprotects the workbook if it's in a protected
state and vice versa.

Thanks for any help given!




Just Learning

Thanks! It works great!

"Don Guillett" wrote:

try

Sub protectunprotecttoggle()
If ActiveWorkbook.ProtectStructure = True Then
ActiveWorkbook.Unprotect Password = "d"
Else
ActiveWorkbook.Protect structu=True, Windows:=False, Password:="d"
End If
End Sub

--
Don Guillett
SalesAid Software

"Just Learning" wrote in message
...
Does anyone have a macro for toggling workbook protection?

E.g., run the macro and it unprotects the workbook if it's in a protected
state and vice versa.

Thanks for any help given!





Don Guillett

glad to help

--
Don Guillett
SalesAid Software

"Just Learning" wrote in message
...
Thanks! It works great!

"Don Guillett" wrote:

try

Sub protectunprotecttoggle()
If ActiveWorkbook.ProtectStructure = True Then
ActiveWorkbook.Unprotect Password = "d"
Else
ActiveWorkbook.Protect structu=True, Windows:=False, Password:="d"
End If
End Sub

--
Don Guillett
SalesAid Software

"Just Learning" wrote in

message
...
Does anyone have a macro for toggling workbook protection?

E.g., run the macro and it unprotects the workbook if it's in a

protected
state and vice versa.

Thanks for any help given!








All times are GMT +1. The time now is 11:27 AM.

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