ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I get Memory used by Current Excel Application? (https://www.excelbanter.com/excel-programming/417590-how-can-i-get-memory-used-current-excel-application.html)

MikeZz

How can I get Memory used by Current Excel Application?
 
Hi,
I've been able to find examples of how to pull a list of applications
currently in Task Manager via the functions below. However, I also want to
track memory usage of the currently running Excel Application.

I've looked around and really can't find an example that works. Based on
the examples I've seen (such as those below), this should be pretty easy to
do.

So, if I have xlApp.hwnd, how can I get the current memory being used by it?

Thanks!
MikeZz


Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA"
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA"
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As
Long



Jim Thomlinson

How can I get Memory used by Current Excel Application?
 
http://www.decisionmodels.com/memlimitsb.htm
--
HTH...

Jim Thomlinson


"MikeZz" wrote:

Hi,
I've been able to find examples of how to pull a list of applications
currently in Task Manager via the functions below. However, I also want to
track memory usage of the currently running Excel Application.

I've looked around and really can't find an example that works. Based on
the examples I've seen (such as those below), this should be pretty easy to
do.

So, if I have xlApp.hwnd, how can I get the current memory being used by it?

Thanks!
MikeZz


Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA"
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA"
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As
Long



Steve Yandl

How can I get Memory used by Current Excel Application?
 
MikeZz,

Here is something you can try.

'-----------------------------------------------

Sub XLmemoryUse()
strComputer = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'EXCEL.EXE'")
For Each objProcess In colProcessList
MsgBox objProcess.WorkingSetSize / 1024
Next
End Sub


'-----------------------------------------------

Steve Yandl



"MikeZz" wrote in message
...
Hi,
I've been able to find examples of how to pull a list of applications
currently in Task Manager via the functions below. However, I also want
to
track memory usage of the currently running Excel Application.

I've looked around and really can't find an example that works. Based on
the examples I've seen (such as those below), this should be pretty easy
to
do.

So, if I have xlApp.hwnd, how can I get the current memory being used by
it?

Thanks!
MikeZz


Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA"
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA"
(ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long)
As
Long






All times are GMT +1. The time now is 01:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com