gpt4 book ai didi

Word 中的 VBA : Getting the script execution time

转载 作者:行者123 更新时间:2023-12-02 19:58:03 24 4
gpt4 key购买 nike

如何获取 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/

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