【发布时间】:2026-01-12 07:15:01
【问题描述】:
我正在尝试让 excel 每隔 XX 秒运行一次更新。
Sub StartTesting()
Call RunAll_ISP 'this call works
End Sub
Sub macro_timer() 'This sub schedules next run in XX seconds.
Dim ScanInterval
ScanInterval = Format(ThisWorkbook.Sheets("Configuration").Range("B5").Value, "hh:mm:ss")
Application.OnTime Now + TimeValue(ScanInterval), "RunAll_ISP", Schedule:=True ' !this macro call throws error!
End Sub
如果我运行 Start_testing 宏,调用就可以了。 如果我运行 macro_timer 宏,它会等待所需的秒数,然后抛出此错误:
无法运行宏“C:\location_of_file\filename.xlsm'!RunAll_ISP'。此工作簿中可能没有该宏或所有宏都可能被禁用
信任中心的宏设置设置为“启用 VBA 宏”
我做错了什么?
【问题讨论】:
-
RunAll_ISP过程在哪里?它在标准模块中吗?是否声明为Public? -
所有子都在 ThisWorkbook 中。尝试公开 - 没有任何区别