LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 413
Default Events problem

I have a single sheet workbook open, with Event code
in the ThisWorkbook module. No other modules.

User makes changes to permitted fields in the sheet
and then attempts to Save. Code runs which creates
a new book, copies the sheet to it (thus not copying
the Thisworkbook code), saves the book with the user's
new name, and leaves it open.

I now remove most of the user's changes to the original
Worksheet (the original book still being open) and then
attempt to close the original using this code:

With Workbooks(wkbkname).Worksheets("Master Order")
.Unprotect Password:= "abc"
.Range("H11").ClearContents
.Range("A2:E15").ClearContents
.Range("A31:K46").ClearContents
.Range("A50:K53").ClearContents
.Range("A57:K63").ClearContents
.Protect Password:= "abc"
End With
Application.EnableEvents = True 'Line1
Workbooks(wkbkname).Close SaveChanges:=True
Application.ScreenUpdating = True
End If
Application.EnableEvents = True
End Sub

When the Close code line runs, the code jumps to the
Before_Close routine which says:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
Application.EnableEvents = True
End Sub

and the changes are not saved.

If I change the line marked as 'Line1 to
Application.EnableEvents = False
the the changes will stick, but Events are turned off.

What can I do, please?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.714 / Virus Database: 470 - Release Date: 02/07/2004


 
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
Events won't Disable! roadkill Excel Discussion (Misc queries) 2 April 26th 06 04:36 PM
events? [email protected] Excel Discussion (Misc queries) 1 September 14th 05 03:26 PM
events Mark[_17_] Excel Programming 1 October 31st 03 09:18 AM
events Mark[_17_] Excel Programming 1 October 29th 03 12:56 PM
Events on shapes Christof De Backere Excel Programming 1 September 2nd 03 03:35 PM


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

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

About Us

"It's about Microsoft Excel"