View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default specific worksheet protection and auto run

Josh

You are 100% correct.

I was the one who "obviously" did not do my homework or my testing properly.

If you have unprotected a sheet and entered some data and saved, that is the
version of the file that gets applied.

The beforeclose did not run on that version so the sheet stays unprotected as it
was saved prior to closing unsaved.

Apologies for the insult and please use the Workbook_Open event.

I'll take mustard on all that crow I'm chowing down on.


Gord

On Thu, 11 Oct 2007 20:25:01 -0700, Josh wrote:

Gord - I will walk you step by step and please tell me what I have missed.

Starting from the beginning.
1. Create new workbook
2. press alt+f11 to display VB
3. copy & paste code from below into ThisWorkbook
4. save workbook
5. enter data into cells A1 & A2 in sheet2
6. save
7. file-exit
8. prompted to save-select no
9. open workbook
10. select sheet2
11. enter data into cell A3 -no protection
12. save
13. file-exit
14. prompted to save-select yes
15. open workbook
16. select sheet2, enter data into cell A4 -protected, will not allow
17. tools-protection-unprotect sheet-enter password
18. save
19. file-exit
20. prompt to save-select no
21. open workbook
22. select sheet2, enter data into cell A4-no protection

I am a beginner to this and I am obviously missing something, so please
humbly point it out.

I do not appreciate you saying that it is obvious I did not test the code.
Now, it might be obvious that I cannot follow directions and/or I am not on
the same page as you are, but I think from the steps above, it is obvious I
tested the code.



"Gord Dibben" wrote:

Josh

Presumably the workbook was saved and closed after you added the BeforeClose
code to Thisworkbook in the first place.

Closing later without saving does not alter that code and the sheets will be
protected.

Same with the workbook_open code. I presume you saved after adding that code.

No difference.

It is obvious to me you did not test but happy to hear you are sorted out.


Gord Dibben MS Excel MVP


On Wed, 10 Oct 2007 17:49:03 -0700, Josh wrote:

I appreciate your responses. I am using 2003 if that makes any difference.
As I understand it, because I choose not to save the changes upon exit, I am
not saving the executable code for protection, therefore my sheets are not
protected the next time the workbook is opened. At any rate, I changed the
code to Workbook_Open and it works like a charm. Thanks again