Hi
I know i am probably pushing my luck a bit and have only got as far as i have as a result of help received from this forum. I offered to help someone out but am struggling with my final piece. I have code to create new appointments and re-occurring appointments in outlook. In order to finish this piece off i am looking to update appointments as well, and if possible identify any conflicting. I have created a userform and the appointment information is transferred to sheet 4 and will always be on line 5 whether it is new or an update. I am desperately trying to learn via books and from any help I am given on here. This is what i have, am I trying to achieve the impossible.???
Public Sub CreateOutlookApptz()
Dim olApp As Outlook.Application
Dim olAppt As Outlook.AppointmentItem
Dim olNs As Outlook.Namespace
Dim CalFolder As Outlook.MAPIFolder
Dim subFolder As Outlook.MAPIFolder
Dim arrCal As String
Dim objPattern As Object
Dim i As Long
On Error Resume Next
Set olApp = Outlook.Application
If olApp Is Nothing Then
Set olApp = Outlook.Application
Err.Clear
End If
On Error GoTo Err_Execute
Set olNs = olApp.GetNamespace("MAPI")
Set CalFolder = olNs.GetDefaultFolder(olFolderCalendar)
i = 5
Do Until Trim(Cells(i, 3).Value) = ""
arrCal = Cells(i, 3).Value
Set subFolder = CalFolder.Folders(arrCal)
Set olAppt = subFolder.Items.Add(olAppointmentItem)
'MsgBox subFolder, vbOKCancel, "Folder Name"
With olAppt
'Define calendar item properties
Set objPattern = olAppt.GetRecurrencePattern
With objPattern
.RecurrenceType = olRecursWeekly
Select Case Weekday(Cells(i, 4).Value)
Case 1
.DayOfWeekMask = olSunday
Case 2
.DayOfWeekMask = olMonday
Case 3
.DayOfWeekMask = olTuesday
Case 4
.DayOfWeekMask = olWednesday
Case 5
.DayOfWeekMask = olThursday
Case 6
.DayOfWeekMask = olFriday
Case 7
.DayOfWeekMask = olSaturday
End Select
.Occurrences = Cells(i, 6).Value
.Duration = DateDiff("n", Cells(i, 4), Cells(i, 4))
.PatternStartDate = Cells(i, 4).Value
.StartTime = Cells(i, 5).Value
End With
.Subject = Cells(i, 1).Value
.Location = Cells(i, 8).Value
.Body = Cells(i, 1).Value & " " & Cells(i, 9).Value
.BusyStatus = olBusy
.Categories = Cells(i, 2).Value
.Save
End With
i = i + 1
Loop
Set olAppt = Nothing
Set olApp = Nothing
Exit Sub
Err_Execute:
MsgBox "An error occurred - Exporting items to Calendar."
End Sub
Really appreciate any help anyone can give
Michelle
Bookmarks