다음을 통해 공유


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

  • Anonymous
    July 02, 2007
    this is really cool, I will for sure make strong use of this! thanks for sharing this cheers martin

  • Anonymous
    July 31, 2007
    The comment has been removed

  • Anonymous
    September 11, 2007
    Can this be done for Outlook 2003?  

  • Anonymous
    September 13, 2007
    Agreed - Works Great - thanks!!!! mark

  • Anonymous
    September 13, 2007
    Mike, 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. Michael

  • Anonymous
    October 11, 2007
    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.

  • Anonymous
    November 07, 2007
    So does anyone know how to bypass the security question: "Allow Access to Outlook..."

  • Anonymous
    November 27, 2007
    Add a digital signature to the macro as described in the MSDN Knowledgebase article. http://msdn2.microsoft.com/en-us/library/aa155754(office.10).aspx

  • Anonymous
    April 03, 2009
    Thanks for this. This will make my working life a lot easier. Wish you success and happiness. Regards, Manas

  • Anonymous
    May 19, 2009
    Awesome!  Glad I searched for this!   Thanks Rick

  • Anonymous
    June 10, 2009
    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 -CJ

  • Anonymous
    November 22, 2009
    The comment has been removed

  • Anonymous
    February 19, 2010
    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!

  • Anonymous
    May 13, 2010
    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. ;-)

  • Anonymous
    May 27, 2010
    The comment has been removed

  • Anonymous
    May 27, 2010
    The comment has been removed

  • Anonymous
    May 27, 2010
    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.

  • Anonymous
    June 18, 2010
    Thanks for sharing, this is exactly what I was trying to do.

  • Anonymous
    July 26, 2010
    Thanks Michael, for both the macro and the instruction how to install :)

  • Anonymous
    January 08, 2011
    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 :)

  • Anonymous
    March 13, 2011
    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.

  • Anonymous
    March 24, 2011
    I get the tun time error 287 meetingRequest.Body = email.Body Could you please advise ?   Thank you

  • Anonymous
    April 07, 2011
    Working like a charm !! awsome job...

  • Anonymous
    May 04, 2011
    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?

  • Anonymous
    May 11, 2011
    This is WONDERFUL.. thank you so much!  Works great.

  • Anonymous
    June 22, 2011
    Great macro!  Thanks man!

  • Anonymous
    September 14, 2011
    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!!

  • Anonymous
    November 08, 2011
    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.

  • Anonymous
    February 01, 2012
    Is it Possible to run the Outlook 2007 macro even system is in sleep mode

  • Anonymous
    February 08, 2012
    Brilliant - massive time saver.  Thanks to OP!

  • Anonymous
    March 01, 2012
    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.

  • Anonymous
    March 08, 2012
    I just find it out that Drag the email to the calender will work the same way.............

  • Anonymous
    May 07, 2012
    Awesome Sauce!   Thank you, wanted Outlook to do this forever.  Appreciate your work.

  • Anonymous
    October 23, 2012
    The comment has been removed

  • Anonymous
    January 24, 2013
    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.

  • Anonymous
    May 06, 2013
    This is way too good!!! Thanks a lot mate. This works greatly:)

  • Anonymous
    July 18, 2013
    I spent HOURS searching for how to do this - thank you!!  I am assuming similar would work with OL 2010??

  • Anonymous
    July 24, 2013
    This is brilliant - thank you so much!!!  I need to add a macro to OL 2010 - I am assuming it would all work similarly?

  • Anonymous
    January 17, 2014
    Thanks :) I learned a lot. I love visual basic

  • Anonymous
    March 25, 2014
    Thanks. added to this Outlook 2007 few minutes ago and I am impressed.