Create Outlook Calender item using Excel ARRAY Data

DeniseTwin

New Member
Joined
Sep 10, 2009
Messages
1
Hi,
From Excel 2003 to Outlook 2003 Calendar:
I have a series of dates and subjects that I want to put in an array and add as an appointment - not a task. I can do this with a single row of data, but not the array. And the array is populated successfully until I add " Const olAppointmentItem = 1 ". Here is what I have.

Sub AddToOLCalendar()

Dim objOL As Object
Dim objItem As Object
Dim lngRow As Long
Dim olApp As Object
Dim olAppointment As Object
Dim olTask() As Variant
Dim i As Long




On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set olApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0

Const olAppointmentItem = 1 'this is required, but then the array doesn't work

Set olAppointment = olApp.CreateItem(olAppointmentItem)


olTask = Range("H15", "I23")
For i = LBound(olTask) To UBound(olTask)
With olAppointment

.Subject = olTask(i, 1)
.Start = DateSerial(2009, 9, 10) + TimeSerial(9, 0, 0)

'DateSerial(olTask(i, 2)) + TimeSerial(9, 0, 0)
.Duration = 60
.Save

End With

Next i


Set olApp = Nothing
Set olAppointment = Nothing
End Sub
***** thank you for any help. **
Denise Z.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top