Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Auto-save on close

In Excel 2000 is it possible to imbed some code in a worksheet that will
automatically save the file when it is closed (rather than go through the
"are you sure...." routine). The standard autosave add-in is already being
used but the user wants to be able to close the sheet and not be prompted -
just have the file saved as default.

TIA

IK
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 179
Default Auto-save on close

Hi
u can use this code.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub

"SthOzNewbie" wrote:

In Excel 2000 is it possible to imbed some code in a worksheet that will
automatically save the file when it is closed (rather than go through the
"are you sure...." routine). The standard autosave add-in is already being
used but the user wants to be able to close the sheet and not be prompted -
just have the file saved as default.

TIA

IK

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Auto-save on close

Thanks for the quick reply.

I saved this code into a module in a workbook but was still prompted with
the "Do you want to save changes..." dialogue when I closed the workbook.
I have not worked with code much so I have probably done something very
basically wrong.

Regards,

Ilya


"Muhammed Rafeek M" wrote:

Hi
u can use this code.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub

"SthOzNewbie" wrote:

In Excel 2000 is it possible to imbed some code in a worksheet that will
automatically save the file when it is closed (rather than go through the
"are you sure...." routine). The standard autosave add-in is already being
used but the user wants to be able to close the sheet and not be prompted -
just have the file saved as default.

TIA

IK

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Auto-save on close

You need to add a line:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
Cancel=True
End Sub

NickHK

"SthOzNewbie" wrote in message
...
Thanks for the quick reply.

I saved this code into a module in a workbook but was still prompted with
the "Do you want to save changes..." dialogue when I closed the workbook.
I have not worked with code much so I have probably done something very
basically wrong.

Regards,

Ilya


"Muhammed Rafeek M" wrote:

Hi
u can use this code.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub

"SthOzNewbie" wrote:

In Excel 2000 is it possible to imbed some code in a worksheet that

will
automatically save the file when it is closed (rather than go through

the
"are you sure...." routine). The standard autosave add-in is already

being
used but the user wants to be able to close the sheet and not be

prompted -
just have the file saved as default.

TIA

IK



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Auto-save on close

Thank you. I added the line but am still getting the message box coming up.

This is probably a really dumb question but should I be inserting the actual
name of the workbook somewhere ?

Have I put the code in the right place ? (It's in Module1 of the workbook)

Regards,

IK

"NickHK" wrote:

You need to add a line:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
Cancel=True
End Sub

NickHK

"SthOzNewbie" wrote in message
...
Thanks for the quick reply.

I saved this code into a module in a workbook but was still prompted with
the "Do you want to save changes..." dialogue when I closed the workbook.
I have not worked with code much so I have probably done something very
basically wrong.

Regards,

Ilya


"Muhammed Rafeek M" wrote:

Hi
u can use this code.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub

"SthOzNewbie" wrote:

In Excel 2000 is it possible to imbed some code in a worksheet that

will
automatically save the file when it is closed (rather than go through

the
"are you sure...." routine). The standard autosave add-in is already

being
used but the user wants to be able to close the sheet and not be

prompted -
just have the file saved as default.

TIA

IK






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Auto-save on close

No, it is a workbook events "Workbook_BeforeClose", so it needs to go on the
ThisWorkBook module.
Sorry, delete the "Cancel=True", thought we were in the _BeforeSave event

NickHK

"SthOzNewbie" wrote in message
...
Thank you. I added the line but am still getting the message box coming

up.

This is probably a really dumb question but should I be inserting the

actual
name of the workbook somewhere ?

Have I put the code in the right place ? (It's in Module1 of the workbook)

Regards,

IK

"NickHK" wrote:

You need to add a line:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
Cancel=True
End Sub

NickHK

"SthOzNewbie" wrote in message
...
Thanks for the quick reply.

I saved this code into a module in a workbook but was still prompted

with
the "Do you want to save changes..." dialogue when I closed the

workbook.
I have not worked with code much so I have probably done something

very
basically wrong.

Regards,

Ilya


"Muhammed Rafeek M" wrote:

Hi
u can use this code.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub

"SthOzNewbie" wrote:

In Excel 2000 is it possible to imbed some code in a worksheet

that
will
automatically save the file when it is closed (rather than go

through
the
"are you sure...." routine). The standard autosave add-in is

already
being
used but the user wants to be able to close the sheet and not be

prompted -
just have the file saved as default.

TIA

IK






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Auto-save on close

Excellent, that's done the trick

Cheers,

IK

"NickHK" wrote:

No, it is a workbook events "Workbook_BeforeClose", so it needs to go on the
ThisWorkBook module.
Sorry, delete the "Cancel=True", thought we were in the _BeforeSave event

NickHK

"SthOzNewbie" wrote in message
...
Thank you. I added the line but am still getting the message box coming

up.

This is probably a really dumb question but should I be inserting the

actual
name of the workbook somewhere ?

Have I put the code in the right place ? (It's in Module1 of the workbook)

Regards,

IK

"NickHK" wrote:

You need to add a line:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
Cancel=True
End Sub

NickHK

"SthOzNewbie" wrote in message
...
Thanks for the quick reply.

I saved this code into a module in a workbook but was still prompted

with
the "Do you want to save changes..." dialogue when I closed the

workbook.
I have not worked with code much so I have probably done something

very
basically wrong.

Regards,

Ilya


"Muhammed Rafeek M" wrote:

Hi
u can use this code.

Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Save
End Sub

"SthOzNewbie" wrote:

In Excel 2000 is it possible to imbed some code in a worksheet

that
will
automatically save the file when it is closed (rather than go

through
the
"are you sure...." routine). The standard autosave add-in is

already
being
used but the user wants to be able to close the sheet and not be
prompted -
just have the file saved as default.

TIA

IK






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Auto-save on close

Don't do this.

You're gonna be upset when you make a disastrous error -- deleting data or
changing code -- and then want to close without saving.

If you do do it, make sure you keep plenty of backups.

SthOzNewbie wrote:

In Excel 2000 is it possible to imbed some code in a worksheet that will
automatically save the file when it is closed (rather than go through the
"are you sure...." routine). The standard autosave add-in is already being
used but the user wants to be able to close the sheet and not be prompted -
just have the file saved as default.

TIA

IK


--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 469
Default Auto-save on close

Hope I understand you with cancel=true close happens without saving changes
correct if so no reply needed
thanks

"Dave Peterson" wrote:

Don't do this.

You're gonna be upset when you make a disastrous error -- deleting data or
changing code -- and then want to close without saving.

If you do do it, make sure you keep plenty of backups.

SthOzNewbie wrote:

In Excel 2000 is it possible to imbed some code in a worksheet that will
automatically save the file when it is closed (rather than go through the
"are you sure...." routine). The standard autosave add-in is already being
used but the user wants to be able to close the sheet and not be prompted -
just have the file saved as default.

TIA

IK


--

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
Auto save and close Frank Excel Worksheet Functions 0 November 19th 09 10:50 AM
Auto Open, Refresh, Save, Close Jimmycooker Excel Discussion (Misc queries) 0 February 6th 06 01:34 PM
Auto-save worksheet on close? [email protected] Excel Discussion (Misc queries) 1 January 2nd 06 02:12 PM
Auto Excel workbook close: save= false during an auto subroutine tomwashere2 Excel Programming 10 June 16th 05 06:23 AM
Auto Close and Save scottwilsonx[_7_] Excel Programming 3 July 7th 04 11:09 AM


All times are GMT +1. The time now is 11:57 AM.

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

About Us

"It's about Microsoft Excel"