Macro to protect and unprotect

  • Thread starter Thread starter tetreaultl
  • Start date Start date
T

tetreaultl

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
 
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
 

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

Back
Top