?
Solved

Scheduling a macro to run at a certain time

Posted on 2006-04-23
12
Medium Priority
?
3,171 Views
Last Modified: 2009-07-29
Just a quick one.

Is there any way to use outlook to run a macro at a specified time everyday/week/month or whatever I choose?

If so, some code snippets would be great also.  Bear in mind the macro will send an email and also contains a connection to a remote database.

Many thanks in advance

Matt Lindsay
0
Comment
Question by:LhXs
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 44

Expert Comment

by:bruintje
ID: 16520404
Hello LhXs,

1. use a vbs script to open outlook and send the email
2. schedule the script on the windows task scheduler for your interval

i think using vbs or even vba will result in the security problem > http://www.slipstick.com/outlook/esecup.htm

so i would advise to use vbsendmail from vb script > http://www.freevbcode.com/ShowCode.Asp?ID=109
and schedule the script

hope this helps a bit
bruintje
0
 
LVL 76

Accepted Solution

by:
David Lee earned 100 total points
ID: 16520729
Greetings, LhXs.

Yes, you can schedule a macro to run via task item and a little code.  Here's are examples from a couple of question I participated in where I did something very much like what you appear to want:

http://www.experts-exchange.com/Applications/MS_Office/Outlook/Q_21372956.html
http://www.experts-exchange.com/Applications/MS_Office/Outlook/Q_21450551.html 

Cheers!
0
 
LVL 74

Expert Comment

by:Jeffrey Kane - TechSoEasy
ID: 16520931
As with all Office programs, Outlook has a built-in Visual Basic editor which is accessed via Tools > Macro >

It does take some Visual Basic know-how to do this, but it's entirely possible.

There is a brief overview about automating tasks in Outlook here:
http://office.microsoft.com/en-us/assistance/CH063566791033.aspx

If you want more detailed information and assistance, please see:
http://www.outlookcode.com  This site is owned and run by Sue Mosher, who also operates slipstick.com.  She's THE Microsoft Outlook MVP.

Jeff
TechSoEasy
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:LhXs
ID: 16532793
I think BlueDevilFan has the best handle on my question so far (Thanks, I think you may have solved one of my previous posts).
The first of those links helps the best, but it's quite a convoluted solution.  I was wondering:

Why isnt there an Application.ontime event for VBA in Outlook like these is in excel or other office apps?

Also; How to get around the security warnings it keeps throwing up?

I really can't understand how Microsoft have missed a boat in outlook by providing the facility to script (VBA) and schedule (calander) but not let you launch apps or scripts from an appointment?

Any further answers or solutions?

Many thanks for you help

Matt
0
 
LVL 76

Expert Comment

by:David Lee
ID: 16533062
> Why isnt there an Application.ontime event for VBA in Outlook like these is in excel or other office apps?
Sorry, Microsoft doesn't consult with me on their design decisions, so I can't answer the question.

> Also; How to get around the security warnings it keeps throwing up?
There are three ways to do this, two of which require third-party software.  One, write an Outlook add-in.  Add-ins have different security constraints.  Two, use ClickYes, a utility that clicks the Yes button when the security dialog pops up.  Three, use Outlook Redemption, a COM component that sidesteps Outlook security.

> but not let you launch apps or scripts from an appointment
You can launch an app or script.  If the script is internal to Outlook, then simply make a call to it.  If the script is external or if you want to launch a separate app, then you have to shell out and run it.
0
 

Author Comment

by:LhXs
ID: 16533126
"> but not let you launch apps or scripts from an appointment
You can launch an app or script.  If the script is internal to Outlook, then simply make a call to it.  If the script is external or if you want to launch a separate app, then you have to shell out and run it."

How do I make a call to my macro from the appointment scheduler form? This is really what I am after, this would solve my problem right off the bat.

Thanks for the continued help.

Matt

p.s. I can't beleive M$ doesnt consult you? How rude!!!
0
 
LVL 44

Expert Comment

by:bruintje
ID: 16533186
as said you can write a vbs script using sendmail on the windows task scheduler this will prevent any security warning and enable you to run the task in the background on schedule
0
 
LVL 44

Expert Comment

by:bruintje
ID: 16533238
disregard my last post :)
0
 
LVL 76

Expert Comment

by:David Lee
ID: 16533316
> I can't beleive M$ doesnt consult you? How rude!!!
I agree!  I've written Bill, but no response yet.

In the code from the two questions I linked to there's a procedure called ReminderFire.  To fire your own macro you just need to put a call to it in that procedure.  Something like this:

Private Sub objReminders_ReminderFire(ByVal ReminderObject As Reminder)
    'Is the reminder for a task
    If ReminderObject.Item.Class = olAppointment Then
        Set objItem = ReminderObject.Item
        'Is the reminder for our task
        If objItem.Subject = "Run MyProcess" Then
            MyProcedureNameGoesHere
            objItem.ReminderTime = DateAdd("h", 1, Now)
            objItem.Save
        End If
    End If
    Set objTaskItem = Nothing
End Sub
0
 
LVL 74

Assisted Solution

by:Jeffrey Kane - TechSoEasy
Jeffrey Kane - TechSoEasy earned 100 total points
ID: 16534237
FYI, I was curious about Application.OnTime not being in Outlook, and came upon this code sample:
http://www.theofficeexperts.com/forum/showthread.php?t=5322

Jeff
TechSoEasy
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question