Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
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 |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
I assume that it would be good enough to keep the screen from flashing form
one sheet to the next as the macro executes? If so then just add something like this to your code... sub whatever() Application.screenupdating = false 'your code here Application.screenupdating = true end sub -- HTH... Jim Thomlinson "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 |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
I have the updating turned off - I was hoping there was a way to actually
make the screen go blank, such as when a screen saver kicks in. Maybe there is a way to alter the screen saver parameters in VBA? -- Bill @ UAMS "Jim Thomlinson" wrote: I assume that it would be good enough to keep the screen from flashing form one sheet to the next as the macro executes? If so then just add something like this to your code... sub whatever() Application.screenupdating = false 'your code here Application.screenupdating = true end sub -- HTH... Jim Thomlinson "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 |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
The easiest way will be to just flip the screen almost closed and then ignore
it. You might be able to adjust the Screen saver via an API but as a guess it will not be easy to do and probably will not be worth doing. -- HTH... Jim Thomlinson "BillCPA" wrote: I have the updating turned off - I was hoping there was a way to actually make the screen go blank, such as when a screen saver kicks in. Maybe there is a way to alter the screen saver parameters in VBA? -- Bill @ UAMS "Jim Thomlinson" wrote: I assume that it would be good enough to keep the screen from flashing form one sheet to the next as the macro executes? If so then just add something like this to your code... sub whatever() Application.screenupdating = false 'your code here Application.screenupdating = true end sub -- HTH... Jim Thomlinson "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 |
#5
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
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 |
#6
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
That sounds like what I need. I will try it and let you know what happens.
Thanks! -- 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 |
#7
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
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 |
#8
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
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 |
#9
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
Well, I haven't tried it on my laptop - it is at home. But it worked on my
desktop at work. I'll try the laptop tonight and let you know. -- 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 |
#10
Posted to microsoft.public.excel.misc
|
|||
|
|||
Screen Off from VBA
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
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) |