Ruddles
Well-known Member
- Joined
- Aug 24, 2010
- Messages
- 5,851
- Office Version
- 365
- Platform
- Windows
I'd like to monitor file activity in a folder on my hard disk from Outlook to enable me to generate emails depending on that activity. I couldn't see anything in Outlook which corresponds to Excel's OnTime method, so I tried to 'borrow' it from Outlook like this:-
Sadly this doesn't work. The Wait works okay but the OnTime complains that there's no macro called TestSub in the workbook when I single-step through the code and crashes when I let the code execute at full speed.
Any ideas for scheduling events to run in Outlook? As the mailbox may not receive mail for hours at a time I can't use the NewMail event.
Code:
Sub UseExcelOnTime()
Dim objExcel As Excel.Application
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Wait Now() + TimeValue("00:00:05")
objExcel.OnTime Now() + TimeValue("00:00:05"), "TestSub"
End Sub
Any ideas for scheduling events to run in Outlook? As the mailbox may not receive mail for hours at a time I can't use the NewMail event.