Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Modify a process priority
During some long VBA code execution, I would like to use other
applications. To run these other applications in a comfortable way, I manually set the Excel process to the lowest priority. But I would like to automatically reduce the Excel application priority with some VBA code, rather than doing it manually each time. Is there any VBA code to modify a process priority? I have Not found that in any field of the Application object Thanks in advance if somebody has already done that Pascal |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Modify a process priority
Pascal,
If you're running on WinXP or Win2k, this can be done with WMI in a vbs script. The script could be incorporated into a VBA routine but I've never tested it in a situation where I would be changing the priority of the process that the script was actually running from. I think I'd be inclined to have two scripts with easy to find shortcuts to allow lowering Excel's priority and to return it to normal. To set priority to 'below normal' this would be the contents: _ __ _ _ _ _ _ _ _ _ _ _ _ _ _ Const BELOW_NORMAL = 16384 strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colProcesses = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'EXCEL.EXE'") For Each objProcess in colProcesses objProcess.SetPriority(BELOW_NORMAL) Next _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ If you really want the lowest priority, you would use Const LOW = 64 To get back to normal, you would use Const NORMAL = 32 Steve wrote in message oups.com... During some long VBA code execution, I would like to use other applications. To run these other applications in a comfortable way, I manually set the Excel process to the lowest priority. But I would like to automatically reduce the Excel application priority with some VBA code, rather than doing it manually each time. Is there any VBA code to modify a process priority? I have Not found that in any field of the Application object Thanks in advance if somebody has already done that Pascal |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Modify a process priority
Thanks a lot, this is what I was looking for and it seems to work fine
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Process Priority | Excel Discussion (Misc queries) | |||
New Priority Column | Excel Discussion (Misc queries) | |||
Change Process Priority | Excel Programming | |||
How to count process running time ( process not finished) | Excel Programming | |||
How to count process running time ( process not finished) | Excel Programming |