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.
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.