Unprotect workbook

  • Thread starter Thread starter Jean-Paul De Winter
  • Start date Start date
J

Jean-Paul De Winter

Hi,
To unprotect a sheet with a click on a pushbutton I wrote:

Private Sub CommandButton5_Click()
Dim thing As Worksheet
For Each thing In Worksheets
thing.Unprotect
Next thing
End Sub

But what is the syntax to unprotect and protect a workbook?
Thanks
 
BTW, an easy way to both code and discover coding for operations that can be
done with menu items or mouse controls is to just start recording a macro,
perform the task you want with the mouse, stop recording and cut what you
want out of what you recorded.
 
Hi
I the code of a pushbutton I wrote:

Private Sub CommandButton5_Click()
ActiveWorkbook.Unprotect
Dim thing As Worksheet
For Each thing In Worksheets
thing.Unprotect
Next thing
End Sub

This seems to work but, when protected I still can choose a cell (but I can
not change anything... that's OK)
What to write so I can't even choose the cell??
Thanks
JP
 
Hi
this is an option of the protect worksheets dialog. To get the syntax
for this you may record a macro while manually protecting a sheet
 

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