Unprotecting Saved Workbook Copies

G

Guest

I need to allow users to manipulate saved copies of a workbook. One
suggestion was to use the before save event to determine if the user is
trying to "save" or "save as". If the user is trying to "save as" the macro
would remove the protection on the workbook. The help menu says you must
first create a new class module and declare an object of type Application
With events. I don't understand the example, how do I do that?
Then, the help menu states that I have to connect the declared object
in the class module with the Application object. How do I do that? I don't
follow the given examples.
Finally, I need to write the code that determines if the user has
selected "save as" and turn the workbook protection off.

Any Help would be appreciated.

Thanks,
-Mike
 
G

Guest

Each workbook has its own beforesave event found in the ThisWorkbook module.

You can get to this through the project explorer in the VBE.

when you get to that module, at the top, in the left dropdown, select
Workbook in the right dropdown select BeforeSave.
It will put in a declaration for the BeforeSave event.

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

End Sub

You can check the SaveAsUI variable to see whether it is a save or saveas

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
if SaveAsUi then
' it is a save as
else
' it is a save
End if
End Sub
 
G

Guest

Thanks for the information, Tom. Unfortunately, it is still not working. I
tried using some information boxes to see if it was attempting to activate
the macro but nothing came up. Here is the code I have:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If SaveAsUI Then
ActiveWorkbook.Unprotect
ActiveSheet.Unprotect
End If
End Sub
If you can see the issue or have other comments I would really apreciate any
help you can offer.

Thanks,
Michael Nowak
 
G

Guest

Looks like I got it today so you can disregard my previous message. Thank
you very much!
-Mike
 

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

Top