gpt4 book ai didi

excel - 如何在 Excel 2016 VBA 中读取已用或可用内存量

转载 作者:行者123 更新时间:2023-12-02 10:07:40 25 4
gpt4 key购买 nike

我似乎找不到返回正在使用的内存或可用内存的 VBA 命令。在 Excel 2013 中有 Application.MemoryUsed 但当我在 Excel 2016 中尝试时,无论我是否使用,都会出现“类型不匹配”

    dim myVar      as variant
myvar = Application.MemoryUsed

    MsgBox CStr(Application.MemoryUsed)

这可能是一件简单的事情。或者?

最佳答案

提出问题后不久我就找到了答案。

在这里找到: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

感谢 Anonimista!

关于excel - 如何在 Excel 2016 VBA 中读取已用或可用内存量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47155175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com