ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to protect and unprotect (https://www.excelbanter.com/excel-programming/293810-macro-protect-unprotect.html)

tetreaultl

Macro to protect and unprotect
 
I want to protect and unprotect a excel sheet with a macro, how do I pass
the password to the command?

Sub Macro12()
'
' Macro12 Macro
' Macro enregistrée l
'

'
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End Sub



Frank Kabel

Macro to protect and unprotect
 
Hi
try something like:
Sub Macro12()
'
' Macro12 Macro
' Macro enregistrée l
Activesheet.unprotect password:="your_password"
' some code

ActiveSheet.Protect password:="your_password",
DrawingObjects:=True, Contents:=True,
Scenarios:=True
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany


tetreaultl wrote:
I want to protect and unprotect a excel sheet with a macro, how do I
pass the password to the command?

Sub Macro12()
'
' Macro12 Macro
' Macro enregistrée l
'

'
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
End Sub




All times are GMT +1. The time now is 10:04 PM.

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