+ Reply to Thread
Results 1 to 3 of 3

Turn Computer off with a Macro

  1. #1
    Registered User
    Join Date
    11-02-2018
    Location
    Wolverhampton
    MS-Off Ver
    2015 (Mac) 15.12.3
    Posts
    17

    Turn Computer off with a Macro

    Is the title of this thread possible to do?

    I have a pretty complex system running that takes between 5-9 hours to run in Excel (all macro based). I was just wondering whether I could put a flag on one of the sheets that calls a macro to save the workbook and turn the computer off?

    I leave simulations running while at work so it would be nice (to save electricity) if once the replay had finished the whole machine sorted itself out. Excel will be the only programme open when running a simulation. This is how I envision running it...

    Please Login or Register  to view this content.
    So, my question. Can I have a sub routine that gets called right at the end of my simulation to save the workbook and turn the whole machine off right from within VBA?

    TIA.

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,443

    Re: Turn Computer off with a Macro

    Hi,

    You can do this with an API call. There's details of it here: https://officetricks.com/excel-vba-s...logoff-reboot/
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Registered User
    Join Date
    11-02-2018
    Location
    Wolverhampton
    MS-Off Ver
    2015 (Mac) 15.12.3
    Posts
    17

    Re: Turn Computer off with a Macro

    Thank you very much for the link, it looks to be exactly what I am looking to do...

    Please Login or Register  to view this content.
    The above line works perfectly and logs off the machine but when I try and change the 4 to a 1 to shut down the computer (as apposed to simply logging the user out), the code does nothing. I click the button the macro is attached to and the system just sits there doing nothing. Any ideas please?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Identical VBA Code works on computer A, throws error on computer B???
    By PWM in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2018, 08:15 AM
  2. Replies: 3
    Last Post: 05-18-2018, 08:20 AM
  3. Excel to open when i turn on my computer
    By meus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2016, 05:39 AM
  4. Replies: 6
    Last Post: 06-28-2013, 08:44 PM
  5. Replies: 0
    Last Post: 02-08-2010, 03:17 PM
  6. [SOLVED] Windows XP : How to turn my Guest account off on an XP computer?
    By joe41 in forum Microsoft Windows Help
    Replies: 4
    Last Post: 11-30-2009, 09:30 AM
  7. Auto Filter on my home computer differs from my work computer.
    By Sbova0226 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 07-08-2009, 03:04 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1