How to turn off MS Macro and reschedule programmatically

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
strtup
Newbie
Posts: 4
Joined: Mon Oct 03, 2005 10:36 pm
Location: Colorado, USA

How to turn off MS Macro and reschedule programmatically

Post by strtup » Wed Mar 22, 2006 5:55 pm

I have a MS macro transferring files from an FTP server to a local drive. The macro runs once a month on a particular date, but needs to run every 2hrs for up to 2-3 days depending on when a certain file arrives. Currently I have to manually check for the particular file, if it's there I have to manually shut off the macro and manually reset for the next month using the "Run When" tab.

I have the code to check for the file (FileExists), but in the macro how do I programmatically turn off and reschedule the Macro in MS Scheduler.

Any help will be greatly appreciated.

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

Post by Marcus Tettmar » Wed Mar 22, 2006 5:59 pm

Hi,

Why do you need to reschedule it? Can you not run it every 2 hours continuously?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

strtup
Newbie
Posts: 4
Joined: Mon Oct 03, 2005 10:36 pm
Location: Colorado, USA

Post by strtup » Wed Mar 22, 2006 6:02 pm

I don't have to reset it every 2 hrs, just once a month after I've received the final file.

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

Post by Marcus Tettmar » Wed Mar 22, 2006 6:05 pm

I must be missing something ... why do you need to reset it ... ?

Why can't you run it every two hours, every day. Have it check for the existence of the file. If it's there it does whatever it needs to do, if it's not it does nothing .... so it doesn't matter when the file arrives, it will detect it and do it's job. When there's no file it will do nothing.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

strtup
Newbie
Posts: 4
Joined: Mon Oct 03, 2005 10:36 pm
Location: Colorado, USA

Post by strtup » Wed Mar 22, 2006 6:05 pm

If I run it ever 2 hour continuously day after day, I'm putting a burden on my system the files i get copy over each other with the macro, which is fine, but after I've received my finaly file I want the macro to shut down so I don't keep downloading the files, at least until the next month when I need to do it again.

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

Post by Marcus Tettmar » Wed Mar 22, 2006 6:11 pm

Ah - I didn't realise the macro was doing something EVERY time you run it - I thought it would do nothing if the file wasn't there.

Why not do this. When you get your final file, store the month number in an INI file. At the start of the script check the ini file and if the current month is the same as the month number in the ini file, jump to the end of the script - so NOTHING happens. Then schedule this every two hours, every day.

E.g. something like this:

Month>mm
ReadIniFile>myini.ini,settings,month,num
If>mm=num,END
..
.. do your stuff here
..
if fiinal file processed
EditIniFile>myini.ini,settings,month,mm
end if
Label>END

So nothing happens unless it's a new month. If it's a new month it keeps checking for the file. When you finally do whatever it is you do with the file and you don't want it to check any more you store the current month number in the ini, and now it will do nothing again until next month ...
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

strtup
Newbie
Posts: 4
Joined: Mon Oct 03, 2005 10:36 pm
Location: Colorado, USA

Post by strtup » Wed Mar 22, 2006 9:22 pm

Thanks alot - good solution.

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