automate save and close of excel

B

BINZA@

I have a pc that shuts down each night automatically using AT command and
shutdown.exe.
My problem is this pc now has 2 x excel documents open at all times with
changes unsaved which are lost when this pc is forced to shutdown, what i am
after is a way of closing excel and saving changes at 17:55 each day of week
which is 10 minutes before pc shutdown.

Thanks for any ideas
 
D

Don Guillett

I use this manually. Adapt within an ontime method
Application.OnTime TimeValue("17:00:00"), "my_Procedure"Sub CLOSE_ALL()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In Application.Workbooks
If w.Name <> ThisWorkbook.Name Then
w.Save
w.Close
End If
Next w
ThisWorkbook.Save
Application.Quit
End Sub
 
D

Don Guillett

go here
http://www.cpearson.com/excel/ontime.htm

sub closeat5
Application.OnTime TimeValue("17:00:00"), "CLOSE_ALL"
end sub

Sub CLOSE_ALL()'In case you want to do manually
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each w In Application.Workbooks
If w.Name <> ThisWorkbook.Name Then
w.Save
w.Close
End If
Next w
ThisWorkbook.Save
Application.Quit
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top