Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
I have code that runs on the workbook BeforeSave event. How do I "cancel" the actual save process here? Depending on what the code returns, I want the save process cancelled and the workbook left on the screen. Thanks Cindy |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Cindy
You can use Cancel = true -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Cindy" wrote in message ... Hi I have code that runs on the workbook BeforeSave event. How do I "cancel" the actual save process here? Depending on what the code returns, I want the save process cancelled and the workbook left on the screen. Thanks Cindy |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Ron
It works. Let me ask you another question - is there a way to have the BeforeSave and BeforeClose code NOT run? What my code does it check that all required data is filled-in. Now, in the design phase, I need to save design changes and code but the BeforeSave and BeforeClose code runs and won't allow me to save without filling in required data. Any ideas? Thanks Cindy -----Original Message----- Hi Cindy You can use Cancel = true -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Cindy" wrote in message ... Hi I have code that runs on the workbook BeforeSave event. How do I "cancel" the actual save process here? Depending on what the code returns, I want the save process cancelled and the workbook left on the screen. Thanks Cindy . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Cindy
Right click on the excel icon next to file on the menubar choose view code The ThisWorkbook is now active paste the code there Every time you press the save(or ctrl-s) button the Workbook_BeforeSave is run and check the cells for you. If not all the cells have a value you can't save Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim myrange As Range Set myrange = Worksheets("Sheet1").Range("A1:A6") If Application.WorksheetFunction.CountA(myrange) < _ myrange.Cells.Count Then Cancel = True End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Cindy" wrote in message ... Thanks Ron It works. Let me ask you another question - is there a way to have the BeforeSave and BeforeClose code NOT run? What my code does it check that all required data is filled-in. Now, in the design phase, I need to save design changes and code but the BeforeSave and BeforeClose code runs and won't allow me to save without filling in required data. Any ideas? Thanks Cindy -----Original Message----- Hi Cindy You can use Cancel = true -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Cindy" wrote in message ... Hi I have code that runs on the workbook BeforeSave event. How do I "cancel" the actual save process here? Depending on what the code returns, I want the save process cancelled and the workbook left on the screen. Thanks Cindy . |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Ron
I'm a little confused. My code is in the BeforeSave event. What my problem is I can't save my design changes because the "BeforeSave" codes runs and want's data filled- in and I need to start with a "blank" form - no data. Cindy -----Original Message----- Hi Cindy Right click on the excel icon next to file on the menubar choose view code The ThisWorkbook is now active paste the code there Every time you press the save(or ctrl-s) button the Workbook_BeforeSave is run and check the cells for you. If not all the cells have a value you can't save Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim myrange As Range Set myrange = Worksheets("Sheet1").Range("A1:A6") If Application.WorksheetFunction.CountA(myrange) < _ myrange.Cells.Count Then Cancel = True End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Cindy" wrote in message ... Thanks Ron It works. Let me ask you another question - is there a way to have the BeforeSave and BeforeClose code NOT run? What my code does it check that all required data is filled-in. Now, in the design phase, I need to save design changes and code but the BeforeSave and BeforeClose code runs and won't allow me to save without filling in required data. Any ideas? Thanks Cindy -----Original Message----- Hi Cindy You can use Cancel = true -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Cindy" wrote in message ... Hi I have code that runs on the workbook BeforeSave event. How do I "cancel" the actual save process here? Depending on what the code returns, I want the save process cancelled and the workbook left on the screen. Thanks Cindy . . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry I have not understand you
I am a Stupid Dutch guy<g You can use this to disable all the events Application.EnableEvents = False restore it with Application.EnableEvents = true -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Cindy" wrote in message ... Hi Ron I'm a little confused. My code is in the BeforeSave event. What my problem is I can't save my design changes because the "BeforeSave" codes runs and want's data filled- in and I need to start with a "blank" form - no data. Cindy -----Original Message----- Hi Cindy Right click on the excel icon next to file on the menubar choose view code The ThisWorkbook is now active paste the code there Every time you press the save(or ctrl-s) button the Workbook_BeforeSave is run and check the cells for you. If not all the cells have a value you can't save Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) Dim myrange As Range Set myrange = Worksheets("Sheet1").Range("A1:A6") If Application.WorksheetFunction.CountA(myrange) < _ myrange.Cells.Count Then Cancel = True End If End Sub -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Cindy" wrote in message ... Thanks Ron It works. Let me ask you another question - is there a way to have the BeforeSave and BeforeClose code NOT run? What my code does it check that all required data is filled-in. Now, in the design phase, I need to save design changes and code but the BeforeSave and BeforeClose code runs and won't allow me to save without filling in required data. Any ideas? Thanks Cindy -----Original Message----- Hi Cindy You can use Cancel = true -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Cindy" wrote in message ... Hi I have code that runs on the workbook BeforeSave event. How do I "cancel" the actual save process here? Depending on what the code returns, I want the save process cancelled and the workbook left on the screen. Thanks Cindy . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Event: open workbook | Excel Discussion (Misc queries) | |||
Event (BeforeSave) - How to test VBA code? Dave P. can you hear me now? | Excel Discussion (Misc queries) | |||
BeforeSave event | Excel Discussion (Misc queries) | |||
BeforeSave Sub | Excel Programming | |||
VBA - BeforeSave - NEED HELP | Excel Programming |