Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Events won't Disable! | Excel Discussion (Misc queries) | |||
events? | Excel Discussion (Misc queries) | |||
events | Excel Programming | |||
events | Excel Programming | |||
Events on shapes | Excel Programming |