Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Personal.xls save on exit (Excel 2000/2003)

    Hi there
    Please help me with the code to save my Personal.xls file to a folder eg ExcelPersonalBackup on the D drive on exit.
    Thank you

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Personal.xls save on exit (Excel 2000/2003)

    Activate the Visual Basic Editor (Alt+F11)
    If necessary, expand Personal.xls in the Project Explorer.
    Double click the ThisWorkbook node of Personal.xls
    Copy the following code:

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    On Error Resume Next
    ThisWorkbook.SaveCopyAs "D:ExcelPersonalBackupPersonal.xls"
    End Sub

  3. #3
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Personal.xls save on exit (Excel 2000/2003)

    I do not seem to get the function to work.
    I pasted it into This workbook portion of the Personal.xls file and closed Excel, but nothing is in the folder I specified.
    Tried it a couple of times, but still no go.
    Any other suggestions?
    Regards

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Personal.xls save on exit (Excel 2000/2003)

    Sorry, I hadn't actually tested the code. It seems that the Before Close event doesn't occur for Personal.xls. Remove the code, and put the following code in a standard module (the type you create by selecting Insert | Module in the Visual Basic Editor):

    Sub Auto_Close()
    On Error Resume Next
    ThisWorkbook.SaveCopyAs "D:ExcelPersonalBackupPersonal.xls"
    End Sub

  5. #5
    3 Star Lounger
    Join Date
    May 2002
    Location
    Smithfield, Free State, South Africa
    Posts
    210
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Personal.xls save on exit (Excel 2000/2003)

    Thanks Hans - spot on.
    Cheers

Posting Permissions

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