如何获取 VBA 脚本执行所需的时间? 我从 PHP 中知道,有类似 microtime() 的东西,它在脚本之前调用一次,之后调用一次,以便能够计算与该值的差异...
有等效的 VBA 吗?
最佳答案
这是我在一个 VBA 项目中使用的示例代码,用于临时测量脚本的性能。
您还可以找到充足的资源来优化脚本的性能
Public Sub generate(ByRef generators() As Generator)
Dim startTime As Double
OptimizePerformance doc
'/////////////////below is the line that matters
startTime = Timer
'////////// your code that is to be measured (in time) here //////////
MsgBox Format(Timer - startTime, "00.00") & " seconds"
removeOptimization doc
End Sub
关于Word 中的 VBA : Getting the script execution time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4219204/