# Solved: Application.OnTime VBA problem



## Gudzy (Jan 26, 2009)

Basically, Im wanting to make a macro I've written run every minute automatically in outlook.

I've tried various bits of code but always get error 348, Object doesn't support this property or method.

The simpliest I've tried is this:

*Sub *RunOnTime()
Application.OnTime Date + TimeSerial(0, 1, 0), "RefreshData"
*End Sub*

*Sub* RefreshData()
RunOnTime
*End Sub*

The error always seems to be at the Application.OnTime line, please could someone help me find what I'm doing wrong.

Thanks for your time
Gudzy


----------



## OBP (Mar 8, 2005)

This is from the Outlook VBA Editor's Help on the Timer Function
Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If


----------



## Gudzy (Jan 26, 2009)

Ok, thanks for the quick reply.

I'll have a play and see if I can get it to work.

EDIT:

I've changed the code to what is found below. The macro I've written is called GetAttachments and is called at the end of this function, whilst newTimer is called at the end of GetAttachments. The problem I seem to have now is the main window doesn't get updated when I've selected another mail message, but does update when I right-click on the selected mail message. I assume this is something to do the do while loop running?

Sub newTimer()
Dim PauseTime, Start, Finish, TotalTime
PauseTime = 10 ' Set duration in seconds
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
' Finish = Timer ' Set end time.
GetAttachments
End Sub


----------

