I need to run a macro triweekly? every 3 weeks... HOW?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
despinal
Newbie
Posts: 16
Joined: Tue Jul 26, 2005 4:49 pm
Location: New York

I need to run a macro triweekly? every 3 weeks... HOW?

Post by despinal » Mon Dec 18, 2006 3:34 pm

Like the subject says: I'm looking to run a macro triweekly (every 3 weeks)

ex. Every 3 weeks - Mondays at 8:15a.m
Starting date: Monday 11/20/2006

Under "Run When" in Macro Scheduler, I have:

Days: Monday
Time: 08:15

I've been having to schedule this macro manually, how can I setup MS to do it for me automatically?

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Dec 18, 2006 4:16 pm

Create an INI file that looks like this:

[MacroName]
LastRun=

Store this in the same folder as your script file. The script will look something like this:

Code: Select all

VBSTART
VBEND

ReadIniFile>IniFile.ini,MacroName,LastRun,dtLast

If>dtLast=
  //If not already set (first time we've ever run, run)
  Let>d=21
Else
  VBEval>DateDiff("d",DateValue("%dtLast%"),Date()),dd
Endif

//If last stored run date was 21 days ago then we can run ...
If>d=21
  ..
  .. your code here
  ..
  //Put today's date in Ini file
  GetDate>Today
  EditIniFile>IniFile.ini,MacroName,LastRun,Today
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts