View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
NickHK[_3_] NickHK[_3_] is offline
external usenet poster
 
Posts: 415
Default Unprotecting Saved Workbook Copies

Mike,
No need for all that class approach.
Open the ThisWorkbook module and paste this:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim WS As Worksheet

If SaveAsUI = True Then
For Each WS In ThisWorkbook.Worksheets
WS.Unprotect "Password"
Next
End If

End Sub

NickHK


"Mike" .(donotspam) ...
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
--
Michael J. Nowak
Energy Systems/Dow Chemical
Texas City, TX