+ Reply to Thread
Results 1 to 8 of 8

[SOLVED] Auto-save on close

  1. #1
    SthOzNewbie
    Guest

    [SOLVED] 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. #2
    Muhammed Rafeek M
    Guest

    RE: 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. #3
    SthOzNewbie
    Guest

    RE: 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. #4
    NickHK
    Guest

    Re: 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" <SthOzNewbie@discussions.microsoft.com> wrote in message
    news:64E3BF7B-1425-425E-AD3E-3FF80A2CB346@microsoft.com...
    > 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. #5
    SthOzNewbie
    Guest

    Re: 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" <SthOzNewbie@discussions.microsoft.com> wrote in message
    > news:64E3BF7B-1425-425E-AD3E-3FF80A2CB346@microsoft.com...
    > > 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. #6
    NickHK
    Guest

    Re: 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" <SthOzNewbie@discussions.microsoft.com> wrote in message
    news:E5C1A1C6-4A00-432C-A0C1-3861CA89FBB5@microsoft.com...
    > 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" <SthOzNewbie@discussions.microsoft.com> wrote in message
    > > news:64E3BF7B-1425-425E-AD3E-3FF80A2CB346@microsoft.com...
    > > > 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. #7
    SthOzNewbie
    Guest

    Re: 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" <SthOzNewbie@discussions.microsoft.com> wrote in message
    > news:E5C1A1C6-4A00-432C-A0C1-3861CA89FBB5@microsoft.com...
    > > 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" <SthOzNewbie@discussions.microsoft.com> wrote in message
    > > > news:64E3BF7B-1425-425E-AD3E-3FF80A2CB346@microsoft.com...
    > > > > 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. #8
    Dave Peterson
    Guest

    Re: 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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1