![]() |
adding before save so it works every time excel opens and with any workbook
I'm trying to implement a App_WorkbookBeforeSave bit of code, but I don't
understand how to get it to work for any open workbook and have it work anytime excel is opened. Cheers! |
adding before save so it works every time excel opens and with any
If you are trying to run the event from Workbook B the code needs to be in
Wbk B. However, once you start the code you can you can make things happen to other workbooks: With Workbooks("A") .Sheets("XXX").Range("A1")=5 .close True End With Close true end sub This will change then Save and Close Wbk A, then Save and Close ThisWorkbook. "Job" wrote: I'm trying to implement a App_WorkbookBeforeSave bit of code, but I don't understand how to get it to work for any open workbook and have it work anytime excel is opened. Cheers! |
adding before save so it works every time excel opens and with any
But, it is not possible to have the code in the personal.xls or some other
place so that the code could be run anytime Excel is open and on any workbook? "gocush" /delete wrote in message ... If you are trying to run the event from Workbook B the code needs to be in Wbk B. However, once you start the code you can you can make things happen to other workbooks: With Workbooks("A") .Sheets("XXX").Range("A1")=5 .close True End With Close true end sub This will change then Save and Close Wbk A, then Save and Close ThisWorkbook. "Job" wrote: I'm trying to implement a App_WorkbookBeforeSave bit of code, but I don't understand how to get it to work for any open workbook and have it work anytime excel is opened. Cheers! |
adding before save so it works every time excel opens and with
To my knowledge the Workbook_BeforeSave event has to be in the ThisWorkbook
module of each workbook that you want it to apply to. However, I think you would work around this by: Not having a Workbook_BeforeSave event. Instead in your Personal.xls have a macro something like: Sub SaveMyFile() 'Enter your Code to do stuff before saving ThisWorkbook.Save End Sub I am not sure if you can set a shortcut key to a macro in Personal.xls but I think you can. If so, go to Tools/Macros/Macro select this macro above /Options and enter s. This will direct the built-in Ctrl+s to this procedure rather than just the normal Save. Keep in mind that doing the above will cause this to happen any time you use Excel. Are you sure you want that? "Job" wrote: But, it is not possible to have the code in the personal.xls or some other place so that the code could be run anytime Excel is open and on any workbook? "gocush" /delete wrote in message ... If you are trying to run the event from Workbook B the code needs to be in Wbk B. However, once you start the code you can you can make things happen to other workbooks: With Workbooks("A") .Sheets("XXX").Range("A1")=5 .close True End With Close true end sub This will change then Save and Close Wbk A, then Save and Close ThisWorkbook. "Job" wrote: I'm trying to implement a App_WorkbookBeforeSave bit of code, but I don't understand how to get it to work for any open workbook and have it work anytime excel is opened. Cheers! |
All times are GMT +1. The time now is 03:42 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com