Option Compare Database
Option Explicit
' ‘*******************SHUT DOWN*********************
Public Function TurnOff()
Shell "shutdown -s -t 02", vbHide
End Function
' ‘*********************REBOOT***********************
Public Function Reboot()
Shell "shutdown -r -t 02", vbHide
End Function
' ‘*********************LOG OFF***********************
Public Function LogOff()
Shell "shutdown -l -t 02", vbHide
End Function
'‘**********************FORCE************************
Public Function ForceReboot()
Shell "shutdown -r -f -t 02", vbHide
End Function
thanks for the heads up. i had not intended to bother closing any open programs, probably did not think it necessary so will do as you advise.
if the shell line is read, will the application.quit be read or will the laptop have closed down before the line is read and executed or will excel close while the lap top is shutting down?
smiler44
when i rebooted and opened Excel, I think it showed that it had closed as if application.quit had not been read.
should I replace t with f a per the page Gasman has given? A very interesting page but my skill level makes it hard for me to understand, sorry
the web page Gasman has given shows /f and /t does / or - make a difference?
Option Compare Database[COLOR="SeaGreen"] 'omit this line in Excel[/COLOR]
Option Explicit
[COLOR="seagreen"]'NOTE switches used below
'/s = shutdown
'/r = reboot
'/l = logoff
'/f = force apps to close without warning
'/t xxx = time delay of xxx seconds e.g. /t 2[/COLOR]
' ‘*******************SHUT DOWN*********************
Public Function TurnOff()
Shell "shutdown /s /t 2", vbHide
Application.Quit
End Function
' ‘*********************REBOOT***********************
Public Function Reboot()
Shell "shutdown /r /t 2", vbHide
Application.Quit
End Function
' ‘*********************LOG OFF***********************
Public Function LogOff()
[COLOR="seagreen"] 'omit /t switch or it doesn't work
' Shell "shutdown /l /t 2", vbHide[/COLOR]
Shell "shutdown /l", vbHide
Application.Quit
End Function
'‘**********************FORCE************************
Public Function ForceReboot()
Shell "shutdown /r /f /t 2", vbHide
Application.Quit
End Function