Unprotect doesn't work in BeforeClose event?

  • Thread starter Thread starter JustADev
  • Start date Start date
J

JustADev

I've got a workbook with one of the worksheets password protected. When
trying to save the workbook as an HTML file, Excel complains about it
and refuses to do so unless the worksheet is unprotected.

I've tried putting in the call to Unprotect at the Before Close event
but found that it doesn't work. Calling the code in a Command Button
does. However, I can't do it this way (for some reason).

So any idea how to work around this thing?

Thanks in advance. :)
 
Why don't you try the following

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
ActiveSheet.Unprotect
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