Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

Have a Macro run farther than 24 hours in the future...

Within Excel XP and VBA, is there a way, using Application.OnTime or some other method, to schedule a macro to execute once at a period more than 24 hours in the future?

I'm trying to avoid using the Windows Task Schedule because it has a habit of crashing  Excel for some reason.
0
dhienzsch
Asked:
dhienzsch
  • 3
  • 2
1 Solution
 
[ fanpages ]IT Services ConsultantCommented:
Hi,

In the routine you had identified as your "OnTime" event, check the current system date (using "Now()") to see if the date you wish the code to run has been reached.  If the date is still in the future, reschedule the "OnTime" event.  24 hours later the routine will trigger again, and eventually the date required will match the system date.

BFN,

fp.
0
 
dhienzschAuthor Commented:
I haven't forgotten about this question... I just haven't had time to test yet.

D
0
 
[ fanpages ]IT Services ConsultantCommented:
:)

That's OK... no rush... we've still got time ;)
0
 
dhienzschAuthor Commented:
Wow... completely spaced providing a response.  

The suggestion worked.  I use a routine where I use NOW to check the system day and if it is anything other than the day I want, I make it sleep for 24 hours from the current time - 15 minutes (so it doesn't cause itself to run continuously).  

Note, this won't work if Macro security level is set to high.
0
 
[ fanpages ]IT Services ConsultantCommented:
Glad we got there in the end.

Thanks for the points/grading.

BFN,

fp.
[ http://NigelLee.info ]
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now