Run a macro everyday at a specified time

G

Guest

Hi!!
I want to be able to run a macro at a specific time every day. I thought
that it might be possible to trigger by setting a recurrent appointment and
having it triggered by the reminder... is this possible?

Thanks!!
 
M

Michael Bauer

Am Fri, 19 Aug 2005 07:01:08 -0700 schrieb mecg96:

Hi,

you can use the Application.Reminder event to start your code. The
sample forces the item to remind again in 10 minutes without displaying
the reminder.

Of course, you should add something to ensure that not every reminder is
handled.

Private Sub Application_Reminder(ByVal Item As Object)
Item.ReminderTime = DateAdd("n", 10, Item.ReminderTime)
Item.Save
End Sub
 
G

Guest

Danke Michael!!


Michael Bauer said:
Am Fri, 19 Aug 2005 07:01:08 -0700 schrieb mecg96:

Hi,

you can use the Application.Reminder event to start your code. The
sample forces the item to remind again in 10 minutes without displaying
the reminder.

Of course, you should add something to ensure that not every reminder is
handled.

Private Sub Application_Reminder(ByVal Item As Object)
Item.ReminderTime = DateAdd("n", 10, Item.ReminderTime)
Item.Save
End Sub
 
D

David C. Holley

I was thinking along the same lines in terms of using a TaskItem. To
control wether or not the code runs, I would create a special category,
assign it to the TI and then check it when the code is called.
 
G

Guest

I was trying the code, but I am not able to use the:

Item.ReminderTime = DateAdd("n", 10, Item.ReminderTime)
Item.Save

The event fires correctly and I have inserted this:

If Item.Subject = "Send MyFile" Then
With Excel.Application.FileSearch
.LookIn = "C:\reports\"
.FileType = msoFileTypeExcelWorkbooks
.Execute
End With

If .FileSearch.FoundFiles.Count = 0 Then

Item.ReminderTime = DateAdd("n", 5, Item.ReminderTime)
Item.Save
End if

I was trying to look for a file, and if was not there I wanted to have it
remind again in 5 minutes to start the process again... but I always get the

"Object doesn't support this property or method" (438)... I have tried
different things but can't get it to work... why does it happen?

Thanks!
 
M

Michael Bauer

Am Mon, 22 Aug 2005 18:16:02 -0700 schrieb mecg96:


It happens because the
If .FileSearch.FoundFiles.Count = 0 Then

block must be within the With statement above.
 
G

Guest

I tried this:

Private Sub Application_Reminder(ByVal Item As Object)
Item.ReminderTime = DateAdd("n", 5, Item.ReminderTime)
Item.Save
MsgBox "Success!!"
End Sub

But I still get the same error (438). Do I need to have a reference to a
specific library... I'm using

VBA, Object libraries for Office, Outlook, Access and Excel 11.0, and DAO
3.6 ... I don't know if this is relevant.
 
M

Michael Bauer

Am Tue, 23 Aug 2005 06:51:02 -0700 schrieb mecg96:

Sorry for confusing. Pllease use a TaskItem instead of an
AppointmentItem.

And additionally check the item type in your code:

If TypeOf Item Is Outlook.AppointmentItem Then
... now check the subject etc.
Endif
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top