Unprotect doesn't work in BeforeClose event?

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. :)
 
Z

zhy

Why don't you try the following

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
ActiveSheet.Unprotect
End Sub
 
Top