• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Running Outlook Macros on a Schedule

Slipstick Systems

› Developer › Code Samples › Running Outlook Macros on a Schedule

Last reviewed on August 25, 2016     23 Comments

How do I run a macro 5 minutes after Outlook starts?

Outlook doesn't have a timer function but you can use Appointment or Task Reminders to trigger macros. Set up an Application_Reminder macro that will do something when a reminder fires. To limit it to running when specific reminders fire, use an If statement to look for words in the subject or a specific category.

If you want the macro to fire a specified time after you restart Outlook, use an Application_Startup macro to create the appointment.

Create an appointment reminder to trigger a macro

If you need to rerun the process kicked off by the reminder, run CreateAppointment macro from the VBA editor at any time.

Other "reminder macros" are at "Open a Webpage when a Task Reminder Fires" and "Send an Email When a Reminder Fires"

' The Private subs go in ThisOutlookSession
Private WithEvents olRemind As Outlook.Reminders

Private Sub Application_Startup()
  CreateAppointment
End Sub

Private Sub Application_Reminder(ByVal Item As Object)
Set olRemind = Outlook.Reminders

If Item.MessageClass <> "IPM.Appointment" Then
  Exit Sub
End If
 
If Item.Categories <> "Run in 5" Then
  Exit Sub
End If
 
' Call your macro here
MsgBox "It works!"

'Delete Appt from calendar when finished
Item.Delete

' Create another appt to repeat the process
CreateAppointment

End Sub

' dismiss reminder 
Private Sub olRemind_BeforeReminderShow(Cancel As Boolean)

    For Each objRem In olRemind
            If objRem.Caption = "This Appointment reminder fires in 5" Then
                If objRem.IsVisible Then
                    objRem.Dismiss
                    Cancel = True
                End If
                Exit For
            End If
        Next objRem
End Sub

' Put this macro in a Module
Public Sub CreateAppointment()
Dim objAppointment As Outlook.AppointmentItem
Dim tDate As Date
' Using a 1 min reminder so 6  = reminder fires at 5 min. 
tDate = Now() + 6 / 1440

Set objAppointment = Application.CreateItem(olAppointmentItem)
      With objAppointment
        .Categories = "Run in 5"
        .Body = "This Appointment reminder fires in 5"
        .Start = tDate
        .End = tDate 
        .Subject = "This Appointment reminder fires in 5"
        .ReminderSet = True
        .ReminderMinutesBeforeStart = 1
        .Save
      End With
End Sub

How to use the macro

First: You will need macro security set to low during testing.

To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security. If Outlook tells you it needs to be restarted, close and reopen Outlook. Note: after you test the macro and see that it works, you can either leave macro security set to low or sign the macro.

Now open the VBA Editor by pressing Alt+F11 on your keyboard.

To use the macro code in ThisOutlookSession:

  1. Expand Project1 and double click on ThisOutlookSession.
  2. Copy then paste the macro into ThisOutlookSession. (Click within the code, Select All using Ctrl+A, Ctrl+C to copy, Ctrl+V to paste.)

Application_Startup macros run when Outlook starts. If you are using an Application_Startup macro you can test the macro without restarting Outlook by clicking in the first line of the Application_Startup macro then clicking the Run button on the toolbar or pressing F8.

To put the code in a module:

  1. Right click on Project1 and choose Insert > Module
  2. Copy and paste the macro into the new module.

More information as well as screenshots are at How to use the VBA Editor

Running Outlook Macros on a Schedule was last modified: August 25th, 2016 by Diane Poremsky

Related Posts:

  • Reset reminders closer to Meeting time
  • Use a macro to create a rule to move messages
  • Scheduling Drafts in Outlook
  • Send an Email When a Reminder Fires

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
23 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Adauto Araujo (@guest_220993)
March 21, 2024 10:23 am
#220993

Wonderfull! Thanks. The only addition I'll do, is to change from this: tDate = Now() + 6 / 1440 to this: tDate = Now() + TimeValue("00:05:00"). I think it's more readable and easier to edit.

0
0
Reply
J.A. Clark (@guest_219313)
May 24, 2022 3:50 pm
#219313

After copy/paste all code as instructed in tutorial and then closing both VBA Editor and Outlook to restart, an error is displayed, 'Compile error: Invalid attribute in Sub or Function'. The first line of cod is highlighted in 'This OutlookSession'.

Running Outlook Office 365 v2202.

Any assistance would be appreciated.

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  J.A. Clark
June 9, 2022 4:41 pm
#219386

This line is highlighted?
Private WithEvents olRemind As Outlook.Reminders

If it's ' The Private subs go in ThisOutlookSession - go ahead and delete it.

0
0
Reply
Krishna (@guest_217405)
January 5, 2021 1:55 pm
#217405

Hi Diane,

Just adding a little comparison info -

I'm looking to run the code like how automatic replies are working. We will receive automatic replies, though the outlook-off. Like this, can VB Macros can work, if Outlook-Off/Close ?

Thanks,
Krishna

0
0
Reply
Krishna (@guest_217404)
January 5, 2021 1:49 pm
#217404

Hi Diane,

Hope all good and HNY ..

We have done some coding in VBA on outlook, our requirement is to run the code over night - But we are not sure, outlook will opened or system is on .. Is there any possibility to make the macros execute at Outlook -Off time.

Any suggestions will be great help.

Many Thanks,
Krishna

0
0
Reply
Prabhat Dewali (@guest_214868)
March 4, 2020 7:21 pm
#214868

Hello Mam,
Thanks for sharing this blog with us I am a beginner in VBA coding. Can you help me with how can I replicate the same appoint or "Create another appt to repeat the process" for the next day or till a certain day in the above code?

"' Create another "Run in 5" appt to repeat the process
"CreateAppointment "

0
0
Reply
Prabhat Dewali (@guest_214879)
Reply to  Prabhat Dewali
March 5, 2020 6:59 pm
#214879

Thanks, I found the solution and now my question is solved it can be done from front end by using the recurrence option.

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Prabhat Dewali
March 5, 2020 8:59 pm
#214880

Yeah, using a recurrence is generally better than recreating a new one every day using a macro.

0
0
Reply
Harrison Griffiths (@guest_214747)
February 12, 2020 7:07 pm
#214747

Hello,

I'm looking to create either a reminder or send an email to the creator of an appointment when the appointment is done or even maybe 5 min after its done. The purpose is for employees who might be working out in the field alone we want them to have a reminder governed by their Outlook calendars to email a colleague or coordinator that they have left work and are safe. Like a Check-In reminder to let the team know they're good and heading home.

Thanks!

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Harrison Griffiths
March 5, 2020 9:05 pm
#214881

I don't think you'd want that automated - based on the appointment as it would generate the message, whether they were safe or not, just based on the meeting end time. They could use a macro to quickly generate a message and set it - no typing required.
https://www.slipstick.com/developer/create-a-new-message-using-vba/

0
0
Reply
Ranjan (@guest_213065)
April 8, 2019 10:34 am
#213065

Hi,
I am looking for a code to create new outlook meeting invite.
I have data in my excel like this.
A-Name
B-ID
C-Recipient 1
D-Recipient 2
E-Subject
F-Body
I am aiming to achieve below. Could you please assist me here.
1. Create a new meeting invite
2. Add the above in right place
3.check for the availability in calendar and set the meeting start and end date(duration is 1hour)
4.Attach required files
5. display/send

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Ranjan
April 8, 2019 11:56 pm
#213072

I have a macro that should meet your needs at
https://www.slipstick.com/developer/create-appointments-spreadsheet-data/#meeting

0
0
Reply
Edwin (@guest_211158)
May 24, 2018 11:19 am
#211158

Hello Diane,

thanks so much for sharing this excellent information with the world. It has been extremely helpful to me and I am grateful.

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 19

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment