Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 791
Default 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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default 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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save, save as, page setup dimmed out in unprotected excel sheet? ccKeithJ Excel Discussion (Misc queries) 3 December 14th 07 07:07 PM
Disable save, save as, but allow save via command button TimN Excel Programming 10 September 1st 06 07:05 PM
How to diasble save and save as menu but allow a save button hon123456 Excel Programming 1 June 12th 06 09:50 AM
how to get disk icon on save button of save as dialog like 2000 RichT Excel Discussion (Misc queries) 2 March 9th 06 08:13 PM
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: harpscardiff[_10_] Excel Programming 8 November 10th 05 12:24 PM


All times are GMT +1. The time now is 10:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"