Hi again all,
I am trying to use VBA to add Outlook appointments in Bulk from Excel.
I have written some code, but can't seem to understand where I am going wrong.
Sub ToCalendar()
'Add reference to MS Outlook Library
Dim oOL As Outlook.Application, oAppoint As Outlook.AppointmentItem
Dim oWS As Worksheet, r As Long, i As Long, sStart As String
Set oWS = Sheet1
r = oWS.Range("A1").CurrentRegion.Row.Count
Set oOL = New Outlook.Application
For i = 2 To r
Set oAppoint = oOL.CreateItem(olAppointmentItem)
With oAppoint
.Start = oWS.Cells(i, 4)
.End = oWS.Cells(i, 5)
sStart = oWS.Cells(i, 3)
sStart = Left(sStart, Len(sStart) - 4 & Year(Date))
'.Start = Cdate(sStart)
.sSubject = "Date"
.Location = oWS.Cells(i, 2) & "" & oWS.Cells(i, 1)
.MeetingStatus = olNONMeeting
.ReminderSet = True
.Save
End With
Next i
Set oOL = Nothing
End Sub
I am receiving an error "Compile Error" on oOL As Outlook.Application
I have searched the net but can't find a simple fix, basically I just want to capture:
Column A: Appointment Name
Column B: Date
Column C: Start Time
Column D: End Time
Column E: Appointment details (Body)
Any help would be great, happy to discard my code if you have a better way to do this,
Cheers
Bookmarks