Adding a VBA Macro to Outlook

Silly me.  When I posted the macros to create Outlook appointments based on email messages and to schedule your drive time, I failed to explain how to add VBA Macros to Outlook.  Well here's how:

  1. For the macro that you want to add, like NewMeetingRequest.bas, right-click on the file hyperlink in Internet Explorer and select Save Target As... and save it to your desktop or in Firefox, click on the hyperlink and select File...Save Page As...and save it to your desktop. (Remember the location where you saved it).

  2. Start Microsoft Outlook 2007

  3. In the Tools menu, select Macros...Visual Basic Editor

  4. In the Visual Basic Editor, you should see a project explorer in the left hand pane.  If you don't see it select View...Project Explorer:

  5. Select File...Import File... and select the .bas file that you downloaded in step 1.  Doing so will add the module to Outlook and it will be listed in the Modules folder.

  6. Now you might want to add the macro to the Quick Access Toolbar in one of the item explorers in Outlook.  To do this, open an explorer by double-clicking on the item in Outlook (like a contact, an appointment, an email message, etc.).  Each class of explorer has its own Quick Access Toolbar, so if you want to add a macro to the quick launch toolbar of existing emails, open an existing email; if you want to add a macro to existing appointments, then open an existing appointment.

  7. Click on the Customize Quick Access Toolbar button and select More Commands... from the menu.
    This is not a real email message (but I'd love to have dinner with Mr. Gates.)

  8. Change the Choose commands from drop down to Macros.

  9. Select one of the macros in the left list and press the Add >> button to add it to the Quick Access Toolbar button list on the Right.

  10. With the new button selected on the right, press the Modify button below to select a new icon and/or display name (to show when hovering over the button); press OK.

  11. Press OK again to save the changes to the Quick Access toolbar

Now the macro is hooked up to a button in the Quick Access toolbar and ready to use.

Comments (41)

  1. Martin says:

    this is really cool, I will for sure make strong use of this!

    thanks for sharing this



  2. Bala says:

    This is awesome; been looking for something like this. However, every time I use this, it keeps asking me to "Allow Access to Outlook…"; Outlook thinks this is a virus or something. Any way of always allowing access?


  3. Mike says:

    Can this be done for Outlook 2003?  

  4. Mark says:

    Agreed – Works Great – thanks!!!!


  5. Synergist says:


    This could probably be fairly easily adapted to Outlook 2003.  For Outlook 2003 you would add the macro to either a toobar or a menu instead of the Quick Access Toolbar.


  6. Daf says:

    Now time to show off.  Can you do that, but make a dropdown in QAT that you can select from a LIST of macros?  Ive been working on this for a week now myself and I am stuck, lol.

  7. SLB says:

    So does anyone know how to bypass the security question: "Allow Access to Outlook…"

  8. Jim says:

    Add a digital signature to the macro as described in the MSDN Knowledgebase article.

  9. Manas says:

    Thanks for this. This will make my working life a lot easier.

    Wish you success and happiness.

    Regards, Manas

  10. Rick says:

    Awesome!  Glad I searched for this!  



  11. CJ says:

    This worked really well, but I got it running in Outlook 2003.  I used the Toolbars menu to add the macro as a button in the Standard toolbar, so while the button creation was a little different, the macro worked just as well.

    Thanks for your great script


  12. It worked for a while but it stopped working and I cant figure out why.  This is my only macro and I don’t know how to completle clean out the VBA code.

  13. dbrn says:

    This is exactly what I was looking for, and it took less than 5 minutes to find the blog, install the macro and test it.  And it works perfectly! Thanks very much!

  14. julied says:

    I like this macro, but I have multiple calendars. How do I get an email to populate a calendar other than the default?  Also, is there a way to specify the date and time – the date and time I want to use is within the body of the email.  So I’d like the appointment to use that date and time.   Thank you so much for sharing the details of creating this macro.


  15. Huet Landry says:

    I imported the macro, but I get an error 91 on the line where the value of "item" is first set.

  16. Huet Landry says:

    I imported the macro, but I get an error 91 on the line where the value of "item" is first set.

  17. Huet says:

    It appears that this works only for messages that are opened, not just selected.

    Being able to use it with selected/previewed essages would be very helpful.

  18. TSingh says:

    Thanks for sharing, this is exactly what I was trying to do.

  19. Mark says:

    Thanks Michael, for both the macro and the instruction how to install 🙂

  20. Rajeev Krishnan says:

    Thank you very much for sharing this – it's such a great time-saver! Have been thinking of doing this for sometime.. Wonder why the people in Redmond don't think of such useful stuff… I'll be sending more of my colleagues to this site 🙂

  21. CJ says:

    Just installed it in Outlook 2007 works like a charm! Thanks a lot!… I still can't understand why Microsoft does not has this function as part of the program.

  22. Tolga Canatar says:

    I get the tun time error 287

    meetingRequest.Body = email.Body

    Could you please advise ?   Thank you

  23. Ayan says:

    Working like a charm !! awsome job…

  24. lap49 says:

    I get the same as Tolga:

    Run time error 287

    meetingRequest.Body = email.Body

    It states "email.Body = <Application-defined or object-defined error>

    Any ideas?

  25. laura says:

    This is WONDERFUL.. thank you so much!  Works great.

  26. Dietz says:

    Great macro!  Thanks man!

  27. Jerry says:

    AWESOME! I've been trying to figure out how to do this for a while. You have saved me quite a bit of time. Thank you!!

  28. Bernd says:

    Thanks a lot! I think MS has included the function now in the latest outlook release but my company gave me only the 2007 version.

  29. alekya says:

    Is it Possible to run the Outlook 2007 macro even system is in sleep mode

  30. Jeb says:

    Brilliant – massive time saver.  Thanks to OP!

  31. Kiran Chitrada says:

    This is where MS fails to see from customer shoes, you have covered. For every new version, MS coming up the same old with bit cosmetic changes, hiding/moving to different navigation they are wasting users and company time and money. Instead developing things like these that are really useful.

  32. MUS says:

    I just find it out that Drag the email to the calender will work the same way………….

  33. Ric says:

    Awesome Sauce!   Thank you, wanted Outlook to do this forever.  Appreciate your work.

  34. Ernesto says:

    I had to comment the line  "Set recipient = meetingRequest.Recipients.Add(email.SenderEmailAddress)  '    recipient.Resolve" because always get the error "missing email in to, cc, bcc" but there is always an address. otherwise great job!

  35. Winston says:

    I agree with Ric.  Awesome.  I always (98% of the time) attach travel around my meetings. Found this and had it working 20 minutes. Thanks again.

  36. Oscar Abarca says:

    This is way too good!!! Thanks a lot mate. This works greatly:)

  37. Cathy Allington says:

    I spent HOURS searching for how to do this – thank you!!  I am assuming similar would work with OL 2010??

  38. Cathy Allington says:

    This is brilliant – thank you so much!!!  I need to add a macro to OL 2010 – I am assuming it would all work similarly?

  39. Belen says:

    Thanks 🙂 I learned a lot. I love visual basic

  40. Venkat says:

    Thanks. added to this Outlook 2007 few minutes ago and I am impressed.

Skip to main content