Word 中的 VBA : Getting the script execution time

标签 vba ms-word execution-time

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

相关文章:

vba - 将制表位转换/替换为逗号

c - 测量程序的 C 执行时间、内存使用和 CPU 负载

c# - C# 和 SQL Server Management Studio 中 SQL 查询的执行时间非常不同

PHP:一次性将 10.000 行插入 mysql 性能

VBA - 自动过滤器 - 总是隐藏确切的值

Excel 根据选择的下拉选项更改单元格值

生成#NAME 的正则表达式? UDF 错误

.net - 将光标定位在 Word 文档的开头/结尾

vba - Excel VBA : setting font style and size while adding text to MS-Word

excel - 如何使用 Excel VBA 确定文件编码类型