![]() |
Save Changes to Add-In
I switched my personal.xls file to an add-in, .xla and when I exit Excel, I
am not prompted to save changes to the .xla file and sometimes, if I forget, I lose changes. Is there a way to put something in the "Workbook_BeforeClose" sub that will save the changes to the add-in? |
Save Changes to Add-In
In the ThisWorkbook module, use code like the following in the BeforeClose
event. With Application .EnableEvents = False ThisWorkbook.Save .EnableEvents = True End With -- Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2008 Pearson Software Consulting, LLC www.cpearson.com (email on web site) "MikeH2" wrote in message ... I switched my personal.xls file to an add-in, .xla and when I exit Excel, I am not prompted to save changes to the .xla file and sometimes, if I forget, I lose changes. Is there a way to put something in the "Workbook_BeforeClose" sub that will save the changes to the add-in? |
Save Changes to Add-In
Application.DisplayAlerts = False ActiveWorkbook.Save -- If this posting was helpful, please click on the Yes button. Regards, Michael Arch. "MikeH2" wrote: I switched my personal.xls file to an add-in, .xla and when I exit Excel, I am not prompted to save changes to the .xla file and sometimes, if I forget, I lose changes. Is there a way to put something in the "Workbook_BeforeClose" sub that will save the changes to the add-in? |
Save Changes to Add-In
Your solution did not seem to work but the one submitted before did:
With Application .EnableEvents = False ThisWorkbook.Save .EnableEvents = True End With Not sure why but I hope this solves the problem. "Michael" wrote: Application.DisplayAlerts = False ActiveWorkbook.Save -- If this posting was helpful, please click on the Yes button. Regards, Michael Arch. "MikeH2" wrote: I switched my personal.xls file to an add-in, .xla and when I exit Excel, I am not prompted to save changes to the .xla file and sometimes, if I forget, I lose changes. Is there a way to put something in the "Workbook_BeforeClose" sub that will save the changes to the add-in? |
Save Changes to Add-In
You may want to add a prompt to Chip's suggested code.
If you're screwing around and delete multiple modules/routines, you may not want to make it automatic. Dim Resp as long if me.saved = true then 'do nothing else resp = msgbox(Prompt:="Wanna save your changes?", buttons:=vbyesno) if resp = vbyes then With Application .EnableEvents = False me.Save 'me is ok, since the code is under the ThisWorkbook module .EnableEvents = True end with end if End With (Untested, uncompiled--watch for typos.) My personal preference is to not to do any development work in my personal.xla file. I'll do all my testing in a separate workbook, then when I'm happy, I'll move the code into my personal.xla. Then I'll just save manually. I keep my personal.xla file marked readonly, too. Just to make it more difficult for me to screw it up. MikeH2 wrote: I switched my personal.xls file to an add-in, .xla and when I exit Excel, I am not prompted to save changes to the .xla file and sometimes, if I forget, I lose changes. Is there a way to put something in the "Workbook_BeforeClose" sub that will save the changes to the add-in? -- Dave Peterson |
Save Changes to Add-In
You final suggestion about doing testing elsewhere is probably the best
approach to this entire issue. That is what I'll do. Thanks! "Dave Peterson" wrote: You may want to add a prompt to Chip's suggested code. If you're screwing around and delete multiple modules/routines, you may not want to make it automatic. Dim Resp as long if me.saved = true then 'do nothing else resp = msgbox(Prompt:="Wanna save your changes?", buttons:=vbyesno) if resp = vbyes then With Application .EnableEvents = False me.Save 'me is ok, since the code is under the ThisWorkbook module .EnableEvents = True end with end if End With (Untested, uncompiled--watch for typos.) My personal preference is to not to do any development work in my personal.xla file. I'll do all my testing in a separate workbook, then when I'm happy, I'll move the code into my personal.xla. Then I'll just save manually. I keep my personal.xla file marked readonly, too. Just to make it more difficult for me to screw it up. MikeH2 wrote: I switched my personal.xls file to an add-in, .xla and when I exit Excel, I am not prompted to save changes to the .xla file and sometimes, if I forget, I lose changes. Is there a way to put something in the "Workbook_BeforeClose" sub that will save the changes to the add-in? -- Dave Peterson |
Save Changes to Add-In
And keep plenty of backups!
MikeH2 wrote: You final suggestion about doing testing elsewhere is probably the best approach to this entire issue. That is what I'll do. Thanks! "Dave Peterson" wrote: You may want to add a prompt to Chip's suggested code. If you're screwing around and delete multiple modules/routines, you may not want to make it automatic. Dim Resp as long if me.saved = true then 'do nothing else resp = msgbox(Prompt:="Wanna save your changes?", buttons:=vbyesno) if resp = vbyes then With Application .EnableEvents = False me.Save 'me is ok, since the code is under the ThisWorkbook module .EnableEvents = True end with end if End With (Untested, uncompiled--watch for typos.) My personal preference is to not to do any development work in my personal.xla file. I'll do all my testing in a separate workbook, then when I'm happy, I'll move the code into my personal.xla. Then I'll just save manually. I keep my personal.xla file marked readonly, too. Just to make it more difficult for me to screw it up. MikeH2 wrote: I switched my personal.xls file to an add-in, .xla and when I exit Excel, I am not prompted to save changes to the .xla file and sometimes, if I forget, I lose changes. Is there a way to put something in the "Workbook_BeforeClose" sub that will save the changes to the add-in? -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 04:04 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com