run a macro at a set time

R

Rob

I want to set a macro to run at a given time.

Application.OnTime 'does this in excel, but I can't find a way in outlook.
any help?

Also, I'd like to be able to pass a parameter to the macro, but that doesn't
seem posible. I'd get round this in excel by putting the parameter in a cell
somewhere, but I don't know where to store it in Outlook.

Thanks in advance
Rob
 
K

keepITcool

hmm..
and then the user closes outlook..
so the ontime wont work.

safer to create a vbscript and
run that as a scheduled task


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob wrote :
 
R

Rob

Thanks for the quick reply. Does the nature of what I'm doing change your
mind or do you still think a vbscript is the right way to go? If so, I'd
presumably need to create the scheduled task programatically. How would I go
about doing that?

context of the problem:
There's a macro which runs when an e-mail is received. It locks up the
machine while it runs, so I'm giving the user the option to defer running the
macro for 5 mins, a bit like a reminder. As this is a relatively short time,
I'm not too worried about the user closing Outlook. Also the nature of the
task performed is such that I could have it run when outlook re-opens.
 
R

Rob

This works with a reference to excel:

excel.Application.OnTime Now + TimeValue("00:05:00"), "myMacro"
 
K

keepITcool

ah..

nope no script:


Probably:
I'd keep my routines inside outlook and monitor
outlook events StartUp and NewMail

Why does it lock up the machine?
is it just a boring routine that needs an instance of excel
(to log stuff in excel files) Does it need user input?

Why not create an excel instance from Outlook?
then maybe you can skip the scheduling and just
perform the routine in THAT instance.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Rob wrote :
 
R

Rob

Thanks. I used a combination of the two methods. I create an instance of
excel from outlook and call a macro within that process. Unfortunatly,
outlook still freezes until the called procedure is over, so I created a
dummy macro so that control was retrurned to outlook.

sub dummy 'called from outlook
application.ontime Now,"RealProcedure"
end sub
sub realprocedure
'...
end sub

Thanks again
Rob
 

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