Excel.Tips.Net Welcome toExcel.Tips.Net

Helpful Links

Tips.Net Home
ExcelTips Home
Ask an Excel Question
Make a Comment

Tips.Net Store

ExcelTips FAQ
ExcelTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

Newest Tips

Removing Borders

Converting to Octal

Filtering Columns for Unique Values

Printing Multiple Worksheets on a Single Page

Changing the Default Font

Creating a Drawing Object

Determining a Value of a Cell

 

Getting Excel Dates into Outlook's Calendar

Summary: If you want to move information from Excel into Outlook, how you do it can be a bit tricky. Here's an example of how you can create appointments in Outlook based on information in your worksheet. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)

Kelly has a worksheet in which she has a table of dates used as closing dates for getting advertisements into the local Yellow Pages. She wants to import these dates into Outlook Calendar with a 72 hour reminder, but some of the dates keep changing to numbers. Kelly wonders how she can get the Excel dates into Outlook like she needs.

Working with Outlook is a bit "higher level" than your run-of-the-mill Excel macro because you need to understand not only how to access Excel data in the macro, but also how to manipulate Outlook data. Without knowing exactly what data you need to transfer from the worksheet to the Outlook appointment, let's examine a short scenario.

Let's assume that you have a worksheet that contains a series of rows, each of which represents a single appointment you want to create. Each appointment contains information in seven columns, as follows, from left to right:

  • Subject. Text that describes the event/appointment (for example, "Yellow Pages Reminder")
  • Location. Text that describes the location of the event, such as a meeting room or a conference call number (this is optional)
  • Start Date/Time. Enter the date and time the event should start using a standard Excel date format (you can display any way you like)
  • Duration. Integer that represents a number of minutes for the appointment
  • Busy Status. Integer that represents an optional value indicating if the time should show as Free (0), Tentative (1), Busy (2), or Out of Office (3)
  • Reminder Time. Integer that represents a number of minutes before the appointment that a reminder should pop-up (as in 4320 which is the number of minutes in 3 days)
  • Body. Text that describes any detail you might want to place in the body of the appointment

With this data in place, you can use a macro to loop through all the rows (starting with the second row, assuming the first row has headings) and create an appointment for each row.

Sub AddAppointments()
    ' Create the Outlook session
    Set myOutlook = CreateObject("Outlook.Application")

    ' Start at row 2
    r = 2

    Do Until Trim(Cells(r, 1).Value) = ""
        ' Create the AppointmentItem 
        Set myApt = myOutlook.createitem(1)
        ' Set the appointment properties
        myApt.Subject = Cells(r, 1).Value
        myApt.Location = Cells(r, 2).Value
        myApt.Start = Cells(r, 3).Value
        myApt.Duration = Cells(r, 4).Value
        ' If Busy Status is not specified, default to 2 (Busy)
        If Trim(Cells(r, 5).Value) = "" Then
            myApt.BusyStatus = 2
        Else
            myApt.BusyStatus = Cells(r, 5).Value
        End If
        If Cells(r, 6).Value > 0 Then
            myApt.ReminderSet = True
            myApt.ReminderMinutesBeforeStart = Cells(r, 6).Value
        Else
            myApt.ReminderSet = False
        End If
        myApt.Body = Cells(r, 7).Value
        myApt.Save
        r = r + 1
    Loop
End Sub

The macro continues to loop through the rows until the Subject column is empty.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7349) applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007

Save Time! ExcelTips has been published weekly since late 1998. Past issues of ExcelTips are available in convenient ExcelTips archives. Have your own enhanced archive of ExcelTips at your fingertips, available to use at any time!
 
Check out ExcelTips Archives today!