在计算机被锁定的时候运行宏 [英] Running macros at scheduled time when pc is locked
问题描述
背景:Windows 7,Office 2010
Background: Windows 7, Office 2010
我目前有2个宏按钮运行,一个宏计算并提取数据,另一个宏选择一个特定的范围并发送一封电子邮件到指定的电子邮件。
I currently have 2 macros running by buttons, one macro calculates and extracts data and the other macro selects a specific range and sends an email to a specified email.
我可以知道如何让这2个宏在我的电脑被锁定的预定时间运行 - 即(在'交换机用户'屏幕)?
May I know how I can get this 2 macros to run at a scheduled time when my pc is locked - i.e. (on 'switch user' screen)?
谢谢,我真诚地感谢任何帮助我可以得到!
Thank you and I sincerely appreciate any help I can get!
推荐答案
Sub tempo()
tps = Now + TimeValue("00:01:00") 'your refresh rate
Application.OnTime tps, "message_ctrl"
End Sub
Sub message_ctrl()
Call Module1.test 'your macro
Call tempo 'this just relaunch schedule when test() finished
End Sub
这里例如每分钟刷新一次,但您可以定义日期或任何内容。
您需要启动一次tempo()或message_ctrl()才能启动循环。也许在workbook_open。
这里的关键是 Application.OnTime 功能。
Here exemple to refresh every minutes, but you can define day or anything. You need to start once tempo() or message_ctrl() to start cycle. Maybe at workbook_open. The key here is the Application.OnTime function.
这篇关于在计算机被锁定的时候运行宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!