View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Import Calendar from Excel

Imran,

Try something like the following. You'll need to set a reference to the
Outlook object library. In VBA, go to the Tools menu, choose References, and
scroll down to and check "Microsoft Outlook N Object Library" where 'N' is
your version of Outlook. The code below assumes that the appointment date
is in column A, the time is in column B, and the subject is in column C,
starting in row 2 on Worksheet(1).

In the GetObject and CreateObject lines of code, change the "12" to your
version of Outlook (12 = 2007, 11 = 2003, 10 = 2002, 9 = 2000, 8 = 97).

Dim OTL As Outlook.Application

Sub AddMeetings()

Dim Rng As Excel.Range
Dim Appt As Outlook.AppointmentItem

Set Rng = ThisWorkbook.Worksheets(1).Range("A2")
If OTL Is Nothing Then
On Error Resume Next
Err.Clear
Set OTL = GetObject(, "Outlook.Application.12")
If OTL Is Nothing Then
Err.Clear
Set OTL = CreateObject("Outlook.Application.12")
If OTL Is Nothing Then
MsgBox "Unable To Reference Outlook Application"
Exit Sub
End If
End If
End If

Do Until Rng.Value = vbNullString
Set Appt = OTL.CreateItem(olAppointmentItem)
Appt.Start = Rng.Value + Rng(1, 2).Value
Appt.End = Appt.Start + TimeSerial(1, 0, 0)
Appt.Subject = Rng(1, 3).Text
Appt.Save
Set Rng = Rng(2, 1)
Loop

End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

wrote in message
oups.com...
Hello,

I have a simple excel sheet with 3 Columns containing date, time &
meeting requests that goes through the year. The meetings are not
recurring and have different subjects. I was wondering if I could
import this schedule into Outlook so that the reminders will pop up
just like any other meeting request. Thanks for your help.

-- Imran