Link to home
Start Free TrialLog in
Avatar of dignified
dignified

asked on

Running Outlook 2003 Macros From a Batch File

I'm looking to automate some stuff from an outlook 2003 batch file. I want to setup a batch file to run at 6am every day to print out some appointments that are formatted using an outlook macro. It would be nice to just call the outlook macro from the commandline and be done with it.

One thing I worry about, is that when I run the macro by hand, I get a dialogue box pop up asking me if I want to grant read permission for 1 minute. Is there also a way I can force outlook to allow the macro to run?
Avatar of David Lee
David Lee
Flag of United States of America image

There's no way I know of to run an Outlook macro from a batch file.  Fortunately though, you don't need to.  Instead, you can convert the macro to VB Script, should only require minor changes, and then run it from the command line.  

There are two options for working around the security warning.

1.  Use Click-Yes.  This is a free third-party utility that sits in your system tray and watches for the security warning dialog-box.  When one pops up it clicks the Yes button for you.  In my opinion it's dangerous though.  Here's a link to it: http://www.contextmagic.com/express-clickyes 

2.  Outlook Redemption.  This too is a third-party utility that allows you to circumvent Outlook security.  It isn't risk free, but I believe it's safer.  It's not free though and is meant more for developers than a casual user.  Here's a link to it: http://www.dimastr.com/redemption
Avatar of dignified
dignified

ASKER

So, even after converting a VB Script, will I still need to worry about the security warnings?
Yes.
Using ClickYes and it should work just fine. Basically it is running on a separate machine which only has access to the calendar, so no emails should be opened. The sole purpose of having outlook on the machine is to convert the calendar to html to put on an intranet site.

Now, how would I go about converting the macro to VBS?
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm getting the following error:

D:\Documents and Settings\me\Desktop\meetingsToHTML.vbs(4, 14) Microsoft V
BScript compilation error: Expected end of statement

Not sure why, it runs fine in outlook. Does this mean rows 4 and 14 or row 4, col 14 or what?
It means line 4 character 14.  That should be this line

    olkSession.Logon "Outlook"

Is a double-quote missing?
Oh I didn't even realize that you changed the code a little bit. I will try adding it just as you've put it then put my changes in.
Yep, had to make a few adjustments.
Well the cscript runs now without giving me errors. But, I am back to my original problem of it only choosing one random appointment out of many.
Will this work with 2007? Maybe I should just try that.
Yes, it should work with 2007, but it should also work with 2003.  I tested it on two different boxes, both with 2003, and it worked perfectly.
This is very frustrating. I'll see if it works on a different box, otherwise I'll try 2007.
Well, after this last Outlook patch came out, nothing works right anymore haha. I'll see if someone can get it working in 2007. Thanks.