Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 284
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Process Priority nastech Excel Discussion (Misc queries) 0 April 25th 06 08:29 PM
New Priority Column ceemo Excel Discussion (Misc queries) 3 April 20th 06 10:02 PM
Change Process Priority John[_88_] Excel Programming 0 October 14th 05 10:29 AM
How to count process running time ( process not finished) miao jie Excel Programming 0 January 13th 05 09:23 AM
How to count process running time ( process not finished) miao jie Excel Programming 2 January 12th 05 06:01 AM


All times are GMT +1. The time now is 08:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"