Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Unprotecting Saved Workbook Copies

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Unprotecting Saved Workbook Copies

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

--
Regards,
Tom Ogilvy

"Mike" wrote:

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Unprotecting Saved Workbook Copies

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


"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy

"Mike" wrote:

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

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Unprotecting Saved Workbook Copies

Looks like I got it today so you can disregard my previous message. Thank
you very much!
-Mike
--
Michael J. Nowak
Energy Systems/Dow Chemical
Texas City, TX


"Tom Ogilvy" wrote:

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

--
Regards,
Tom Ogilvy

"Mike" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unprotecting Workbook Anto111 Excel Discussion (Misc queries) 1 June 22nd 08 01:37 PM
why do I get a warning when unprotecting a workbook charob Excel Worksheet Functions 1 December 28th 07 02:55 PM
how to change # or copies to print in a saved sheet? John Excel Discussion (Misc queries) 0 August 21st 06 05:01 PM
Protecting/Unprotecting Workbook Sonny Maou Excel Programming 4 February 18th 04 04:59 PM
unprotecting workbook Jeff Excel Programming 2 December 10th 03 04:11 PM


All times are GMT +1. The time now is 05:08 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"