Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 8 of 8

Thread: Shutting Down Computer at a certain time

  1. #1
    New Member
    Join Date
    Feb 2002
    Location
    Benicia, CA
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have tried searching for this but is there a way to have my computer shut down without saving anything at a certain time using VBA code? Any help would be great.

    Thanks,
    Greg

  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    By some strange coincidence, I have actually programmed such an application. What my app did was when Excel was opened, the user was prompted with a userform that asked the user to enter a time. the application then waited until that time using "Application.Wait" then called this function with the value "True" to shut down NT.


    Private Declare Function ExitWindowsEx Lib "user32.dll" _
    (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    Public Sub Main()
    frmTime.Show
    End Sub

    Public Sub ShutDownNT(Force As Boolean)
    ' Shut Down NT
    Dim ret As Long
    Dim Flags As Long

    Flags = EWX_SHUTDOWN
    If Force Then Flags = Flags + EWX_FORCE
    ExitWindowsEx Flags, 0
    End Sub


    I hope this helps you. I can't possibly think what you'd want to use this for. I just know exactly why I wanted it.

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Millbank, London, UK
    Posts
    1,790
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Mark... you wanted all power cut when the bailiffs came round, right ?


  4. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    359
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Is there anything computer-wise that CAN'T be done with Excel???

  5. #5
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-15 13:06, Cosmos75 wrote:
    Is there anything computer-wise that CAN'T be done with Excel???
    Windows is VB Based so there isn't too much
    Xl cannot do since Excel uses VBA.
    Kind Regards,
    Ivan F Moala From the City of Sails

  6. #6
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-04-15 12:41, Chris Davison wrote:
    Mark... you wanted all power cut when the bailiffs came round, right ?

    Suffice to say, I'd love to say why I made it, but I fear that someday my boss will find out about my 'net use at work and stumble across these archives and I don't want to get myself into even more trouble.

    Mind you, this is the same boss that calls me into his office to ask him how to open a *.zip file.

    "Um, yeah, you just double-click on it since you've got WinZip installed."

  7. #7
    New Member
    Join Date
    Feb 2002
    Location
    Benicia, CA
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thank you very much for the response. Would I need to change something if i am using XP? The reason I want it is kind of stupid. I usually leave my home computer on when i go to work but am usually sending files (big mp3 mixes) to some friends so I want to be able to just shut my computer down after those are done instead of leaving my computer on all day. Anyway, thank you. I will give it a try when i get home.

    Greg

    [ This Message was edited by: greg0226 on 2002-04-15 13:28 ]

  8. #8
    New Member
    Join Date
    Feb 2002
    Location
    Benicia, CA
    Posts
    31
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    What else do i need to do with this code because I can't seem to get it to work? Thanks.

    Greg

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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