How to call outlook in Excel to add a task or calendar

Source: Internet
Author: User

Several people have asked how to use VBA in Excel to call outlook or other office applications.ProgramIn fact, the practice is very simple. The key is to master and use the object model of the target application. Here is an example we have done before: Create a schedule in Excel and then call outlook, add the scheduler to the task becauseCodeI used it at the time, so it was rough.

Excel table:

Code:

Public   Sub Writemediutlooktask ()


Dim Task As Outlook. taskitem



Dim RNG As Range



Dim I As   Long

For I =   3   To   34 Step 1

If Range ( " B "   & I). Value <>   ""   Then

Set Task = Outlook. application. createitem (oltaskitem)

Task. Subject =   " Note: "   & Range ( " B "   & I). Value &   " - "   & Range ( " C "   & I). Value

Task. startdate = Range ( " A "   & I). Value

Task. duedate = Range ( " A "   & I). Value

Task. Save

End   If

If Range ( " D "   & I). Value <>   ""   Then

Set Task = Outlook. application. createitem (oltaskitem)

Task. Subject =   " Review: "   & Range ( " B "   & I -   2 ). Value &   " - "   & Range ( " C "   & I -   2 ). Value

Task. startdate = Range ( " A "   & I). Value

Task. duedate = Range ( " A "   & I). Value

Task. Save

End   If

If Range ( " E "   & I). Value <>   ""   Then

Set Task = Outlook. application. createitem (oltaskitem)

Task. Subject =   " Review: "   & Range ( " B "   & I -   4 ). Value &   " - "   & Range ( " C "   & I -   4 ). Value

Task. startdate = Range ( " A "   & I). Value

Task. duedate = Range ( " A "   & I). Value

Task. Save

End   If



Next



End sub

Download the complete Excel file: exceloutlook

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.