Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Well, it sorta works on the laptop. It does turn the screen off, but it
kicks back on after 1-2 seconds, even if I set it to wait 10-20-30 seconds. A couple of times it stayed off maybe 4-5 seconds, but other than that, it basically just kicked right back on. I had had the same problem on my desktop at work when I just used the code you posted. But when I substituted a delay routine I use for some other things, it worked on my desktop for whatever period of time I wanted. But on the laptop it almost always kicked right back on regardless of the routine I used. I can set my macro to send the MONITOR_OFF command each time it runs through its routine - that will probably work for me. But any ideas as to why it won't stay turned off? -- Bill @ UAMS "PapaDos" wrote: I found them in the MSDN documentation for Visual Studio, but they are well published all over the web... Is your screen really turning off ? On my laptops, the best I can manage is to put it in standby mode, even when I use the MONITOR_OFF command... -- Regards, Luc. "Festina Lente" "BillCPA" wrote: Worked like a charm! The hex codes you show for SC_MONITORPOWER, WM_SYSCOMMAND, etc. - where can those be found? -- Bill @ UAMS "PapaDos" wrote: You can try something based on this code, but it will probably only put the screen in "Standby" mode... The sub turns the monitor OFF and ON again 30 seconds later... Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long Sub setMonitor() Const SC_MONITORPOWER As Long = &HF170& Const WM_SYSCOMMAND As Long = &H112& Const MONITOR_ON As Long = -1& Const MONITOR_OFF As Long = 2& Const MONITOR_STANDBY As Long = 1& Const delay As String = "0:00:30" Debug.Print On Error GoTo bye Debug.Print Now, "MONITOR OFF" SendMessage Application.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF Application.Wait (Now + TimeValue(delay)) ' Debug.Print Now, "MONITOR ON" ' SendMessage application.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON ' Application.Wait (Now + TimeValue(delay)) ' Debug.Print Now, "MONITOR IN STANDBY" ' SendMessage Application.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_STANDBY ' Application.Wait (Now + TimeValue(delay)) bye: SendMessage Application.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON Debug.Print Now, "MONITOR ON" End Sub -- Regards, Luc. "Festina Lente" "BillCPA" wrote: I have an analysis macro I run every now and then that runs anywhere from 2-6 hours. If I run it on my desktop, I turn my monitor off while it runs. Is there some way in VBA to turn off the screen on a laptop while the macro executes? -- Bill @ UAMS |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
print box opens in right screen of dual screen setup why | Excel Discussion (Misc queries) | |||
How Do I Autofit To Screen Size | Excel Worksheet Functions | |||
Need to convert point on screen to various screen resolutions | Excel Discussion (Misc queries) | |||
Hyperlink Screen Tips not cross platform | Excel Discussion (Misc queries) | |||
How do I move the current cell to the top of the screen? | Excel Discussion (Misc queries) |