+ Reply to Thread
Results 1 to 10 of 10

How to check Laptop Lid state for open or closed in VBA Excel

  1. #1
    Registered User
    Join Date
    01-24-2023
    Location
    Mequon, Wisconsin
    MS-Off Ver
    365
    Posts
    3

    How to check Laptop Lid state for open or closed in VBA Excel

    I need to get the Lid State of open or closed for a project am working on to let elderly person know to open their laptop to see reminders.
    Can anyone point me to code that will check internal laptop Lid state?
    Thanks.

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    4,950

    Re: How to check Laptop Lid state for open or closed in VBA Excel

    Maybe I am missing something here but does the lid not need to be up and the computer switched on with Excel being the current program open with a way to activate a popup to give you a message?
    Experience trumps academics every day of the week and twice on Sunday.

  3. #3
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit
    Posts
    789

    Re: How to check Laptop Lid state for open or closed in VBA Excel

    @jolivanes, in the "Power options" of Windows under the item "Choose what closing the lid does" you can choose "Do nothing" so Excel could be left running with the lid closed. Excel can produce sounds and if you have an operating external display you can also see what's going on. OP doesn't say if he has an external display so I suppose that he could make Excel beep and hopefully, if elderly don't have hearing problems, have them open the lid to see reminders. He could even have Excel send emails on their smartphones as reminders.
    Last edited by rollis13; 01-26-2023 at 03:30 AM.

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,549

    Re: How to check Laptop Lid state for open or closed in VBA Excel

    If you can detect that the lid is closed then you can send a text message. Of course, you can just send a text message anyway whether the lid is open or not. It will still show up in two places.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  5. #5
    Registered User
    Join Date
    01-24-2023
    Location
    Mequon, Wisconsin
    MS-Off Ver
    365
    Posts
    3

    Re: How to check Laptop Lid state for open or closed in VBA Excel

    I am actually looking for VBA code or an API call to other code that can pass into an existing VBA macro that is running
    I need to send text-to-speech to let the person know to "open the laptop lid" if they close it so that they will
    see reminders set for them at specific times.
    This is a project for elderly in assisted living whos memories are failing.
    So It is not about what to do when Lid is closed such as power settings, but code that will be able to do
    Text to speech to say open lid.
    If you know of code that can do this, I would greatly appreciate it if you could paste in post.
    Thank you.

  6. #6
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit
    Posts
    789

    Re: How to check Laptop Lid state for open or closed in VBA Excel

    No idea how to test if lid is closed but for the speech you could use something like this:
    Please Login or Register  to view this content.

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    4,950

    Re: How to check Laptop Lid state for open or closed in VBA Excel

    @ rollis13.
    Wow, another example that we're never too old too learn. Thank you very much.

  8. #8
    Registered User
    Join Date
    01-24-2023
    Location
    Mequon, Wisconsin
    MS-Off Ver
    365
    Posts
    3

    Re: How to check Laptop Lid state for open or closed in VBA Excel

    I already have the speech down/
    I did find a way however. I found code using AutoHotKey that I can call to do the check. And it works amazingly. So thank you all for trying. Unless you know of VBA code that can do the same, I am good for now.
    thanks much.

  9. #9
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit
    Posts
    789

    Re: How to check Laptop Lid state for open or closed in VBA Excel

    Quote Originally Posted by KenSiegel View Post
    I found code using AutoHotKey that I can call to do the check.
    Do you mind sharing the information because I find it quite interesting.

  10. #10
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 2209 64-bit
    Posts
    21,671

    Re: How to check Laptop Lid state for open or closed in VBA Excel

    Quote Originally Posted by KenSiegel View Post
    I already have the speech down/
    I did find a way however. I found code using AutoHotKey that I can call to do the check. And it works amazingly. So thank you all for trying. Unless you know of VBA code that can do the same, I am good for now.
    thanks much.
    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

    If a member helped you solve your problem, consider adding to their reputation by clicking http://www.seiglefamily.com/excel/ad...niconsmall.jpg below their name.

    If you solved your own problem, please provide your solution so that somebody seeing this thread in a search for the same problem will see how it was solved.
    Jeff
    | | |?| |?| |?| |?| | |:| | |?| |?|
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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. Using VBA to open a closed excel file
    By KColgrove in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-23-2019, 01:22 AM
  2. Replies: 1
    Last Post: 11-15-2017, 01:02 PM
  3. Update closed workbooks & check if already open
    By Desauv86 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-25-2016, 08:57 AM
  4. Check if a Word File is Open and If Open Close it with Excel VBA.
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-10-2012, 11:14 AM
  5. Check if file is open and open if closed
    By Jockster in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-22-2010, 08:18 AM
  6. automatically open a file with excel closed
    By juanjose in forum Excel General
    Replies: 2
    Last Post: 08-26-2009, 12:07 PM
  7. [SOLVED] Check Excel's state to see if a workbook is loaded in App
    By Chris w. in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-24-2005, 08:06 PM

Tags for this Thread

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