Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Protect Worksheet / Workbook in BeforeSave Event

I was unprotecting and reprotecting all Worksheets and the Workbook in a
Workbook.BeforeSave Event and it had been working fine for weeks. Now all of
a sudden it won't work. It still works from normal Sub's and even from
inside the Workbook.BeforeClose Event. I can't find any changes to the
BeforeSave Event that would account for this. I tried stripping my
BeforeSave Event down to just doing an explicit Protect on a single Worksheet
by index with a literal Password and it still doesn't work. I tried it in a
brand new Workbook's BeforeSave Event and it still works. I'm using XL 2k on
XP Pro SP2. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Protect Worksheet / Workbook in BeforeSave Event

I wonder if you used

Application.EnableEvents = FALSE

and then didn't turn events back on with

Application.EnableEvents = TRUE

at some time before you save.

"tc69" wrote:

I was unprotecting and reprotecting all Worksheets and the Workbook in a
Workbook.BeforeSave Event and it had been working fine for weeks. Now all of
a sudden it won't work. It still works from normal Sub's and even from
inside the Workbook.BeforeClose Event. I can't find any changes to the
BeforeSave Event that would account for this. I tried stripping my
BeforeSave Event down to just doing an explicit Protect on a single Worksheet
by index with a literal Password and it still doesn't work. I tried it in a
brand new Workbook's BeforeSave Event and it still works. I'm using XL 2k on
XP Pro SP2. Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Protect Worksheet / Workbook in BeforeSave Event

Nope, Application.EnableEvents was True. I stepped right throught the
Protect call and watched it not change the Worksheet's ProtectContents
Property AND not set an error!?!

Doh! I just realized what changed that made it stopped working. I created
a Macro that emulates the Save option so I could do stuff after the Save
since there's no Workbook.AfterSave Event. Apparently, when
Workbook.BeforeSave is called due to a Workbook.Save call vs. directly from
the predefined Save Control, Protect won't work and won't generate an error.
I actually had a similar problem with calling Workbook./Worksheet. Unprotect
and Workbook.Save from Workbook.BeforeClose if the Event was raised due to a
Workbook.Close call vs. directly from the predefined Close Control.

I think I read some post about certain XL menu commands (or their
corresponding VBA methods) not working from inside certain Events, but I
can't find it.

Anyone know about this problem?

"Barb Reinhardt" wrote:

I wonder if you used

Application.EnableEvents = FALSE

and then didn't turn events back on with

Application.EnableEvents = TRUE

at some time before you save.

"tc69" wrote:

I was unprotecting and reprotecting all Worksheets and the Workbook in a
Workbook.BeforeSave Event and it had been working fine for weeks. Now all of
a sudden it won't work. It still works from normal Sub's and even from
inside the Workbook.BeforeClose Event. I can't find any changes to the
BeforeSave Event that would account for this. I tried stripping my
BeforeSave Event down to just doing an explicit Protect on a single Worksheet
by index with a literal Password and it still doesn't work. I tried it in a
brand new Workbook's BeforeSave Event and it still works. I'm using XL 2k on
XP Pro SP2. Thanks!

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
Need help with BeforeSave event Chuck M Excel Programming 4 March 6th 07 02:15 PM
BeforeSave event Carl Bowman Excel Discussion (Misc queries) 4 February 6th 05 12:28 PM
BeforeSave sub won't save another workbook when triggered by another event sub Brad Yundt Excel Programming 1 June 3rd 04 03:12 AM
BeforeSave event j23 Excel Programming 0 April 6th 04 11:15 AM
BeforeSave workbook event Cindy Excel Programming 15 February 10th 04 04:28 PM


All times are GMT +1. The time now is 05:33 PM.

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"