+ Reply to Thread
Results 1 to 2 of 2

Auto-save worksheet on close?

  1. #1

    Auto-save worksheet on close?

    Hello!

    At work we have a worksheet that is always open. A lot of people are
    adding data to the file (on only one computer). But we have a problem;
    people are shutting down excel and pressing "no" on the "Do you want to
    save changes"-notification.

    So;
    How could I disable the notification, and instead put on a macro like
    this;

    Private Sub Worksheet_Close()
    Worksheet.Save
    End Sub
    ________________________________

    Well, I'm no programmer, so it's surely not right, but how could I
    easily do what I want?

    Thanks.
    =D8ystein


  2. #2
    Roger Govier
    Guest

    Re: Auto-save worksheet on close?

    Hi
    You could enter something like the following in the Workbook module

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.DisplayAlerts = False
    If ActiveWorkbook.ReadOnly = True Then
    ActiveWorkbook.Close SaveChanges:=False
    Exit Sub
    Else
    ActiveWorkbook.Close SaveChanges:=True
    End If
    Application.DisplayAlerts = True
    End Sub

    This will check to see that the file has not been opened as Read Only,
    and if not, it will save it before closing regardless of any choices
    made by the user.

    --
    Regards

    Roger Govier



    [email protected] wrote:
    > Hello!
    >
    > At work we have a worksheet that is always open. A lot of people are
    > adding data to the file (on only one computer). But we have a problem;
    > people are shutting down excel and pressing "no" on the "Do you want
    > to save changes"-notification.
    >
    > So;
    > How could I disable the notification, and instead put on a macro like
    > this;
    >
    > Private Sub Worksheet_Close()
    > Worksheet.Save
    > End Sub
    > ________________________________
    >
    > Well, I'm no programmer, so it's surely not right, but how could I
    > easily do what I want?
    >
    > Thanks.
    > Øystein




+ 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