unlock and lock VBAProject

  • Thread starter Thread starter Lenny_821
  • Start date Start date
L

Lenny_821

Because when I try to save the document it give's me the followin
message;
"you cannot save to this fileformat when the VBA project is protected"

here's the code;

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)

Dim MyVar

On Error GoTo EndHere

Application.ScreenUpdating = False
ActiveWorkbook.Unprotect

'my code here

Application.ScreenUpdating = True
ActiveWorkbook.Protect

Exit Sub

EndHere:
MyVar = MsgBox(Text1, 16, Text2)

End Su
 
I've seen that message when I saved a workbook with a protected project in the
xl95 file format. (I didn't try other fileformats.)

But do you really need to use whatever file format you're using?

And what file format are you using?
 

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