2017-11-07 19 views
1

使用中のメモリまたは使用可能なメモリを返すVBAコマンドが見つからないようです。 は、Excel 2013であったApplication.MemoryUsedが、私は、私はExcelの使用量または空きメモリ量を読み取る方法2016 VBA

dim myVar  as variant 
     myvar = Application.MemoryUsed 

または

MsgBox CStr(Application.MemoryUsed) 

を使用するかどうかに関係なく、エクセル2016年に、私は「型の不一致」を得ることをしようとすると、それはおそらく、単純なことです。または?

答えて

1

質問をした直後に答えが見つかりました。

はこちらをご覧ください:Anonimistaへhttps://social.msdn.microsoft.com/Forums/office/en-US/e3aefd82-ec6a-49c7-9fbf-5d57d8ef65ca/check-size-of-excelexe-in-memory?forum=exceldev

Declare Function GetCurrentProcessId Lib "kernel32"() As Long 

    Function GetMemUsage() 

    ' Returns the current Excel.Application 
    ' memory usage in MB 

    Set objSWbemServices = GetObject("winmgmts:") 
    GetMemUsage = objSWbemServices.Get(_ 
     "Win32_Process.Handle='" & _ 
     GetCurrentProcessId & "'").WorkingSetSize/1024 

    Set objSWbemServices = Nothing 

    End Function 

感謝を!

+0

私は間違っている可能性がありますが、これはKB単位の作業セットサイズを返すと思います。 Windows APIの 'GetProcessWorkingSetSize()'関数[documentation](https://msdn.microsoft.com/en-us/library/windows/desktop/ms683226(v = vs.85).aspx)は、メモリの場所を返しますバイト単位。 – PaulDH

関連する問題