Inactive workbook auto save & close

Closed
rob - Mar 8, 2010 at 08:20 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Mar 8, 2010 at 08:52 AM
Hello,
I have got a excel workbook that i have programed to open automatically at 2am, when it opens it sends an email telling the recipiant the value in a paticular cell. what i am struggling to do is to then get it to auto save and close. i have looked at many examples of vba code which i guess would work fine but in the normal working day i need the users of the workbook to be able to modify cell values etc. what i need is a macro to add onto my existing code so that in the early hours of the morning once the email is sent i need it to auto save and close but if its opened in the day by a user i dont want to auto save and close then. so i was thinking that if the workbook isnt modified after say 2 hours then the work book would save and close automatically. any ideas ?
it will be a shared workbook and will be saved in earlier versions of excel.
Related:

1 response

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Mar 8, 2010 at 08:52 AM
Rob see if this works

Private Sub Workbook_Open()

Dim toProcessSheets As Variant
Dim thisSheet As Variant

'name of sheets to process
toProcessSheets = Array("Sheet1", "niel")

For Each thisSheet In toProcessSheets

Sheets(thisSheet).Select

Call ThisWorkbook.SendEMail

Next

'save the work book
ActiveWorkbook.Save

'close excel application
Application.Quit
End Sub
0