Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Forgot to save a workbook after adding additional info | Excel Discussion (Misc queries) | |||
when opening an Excel Workbook, another blank workbook also opens | Excel Discussion (Misc queries) | |||
when opening an Excel Workbook, another blank workbook also opens | Excel Discussion (Misc queries) | |||
Personal workbook opens when Excel opens | Excel Discussion (Misc queries) | |||
Excel Workbook opens after a very very long time | Excel Worksheet Functions |