I have a customer that wants to see the daily appointments from Outlook.
I got so far and then I get messages that says "Object dosen't support this property or method" The problem occures in the "rs(.." statements. I have not found any help relating to this problem. If there is, please point me to them.
Working with Office 2007 and windows XP.
Thanks,
Richard
I got so far and then I get messages that says "Object dosen't support this property or method" The problem occures in the "rs(.." statements. I have not found any help relating to this problem. If there is, please point me to them.
Working with Office 2007 and windows XP.
Code:
Function showCalendar(strAns1)
Code:
[COLOR=black][FONT=Verdana]Dim ol As Object[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Dim olns As Object[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Dim objFolder As Object[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Dim objAllAppointment As Object[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Dim objRecurPattern As Object[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Dim db As Database, rs As Recordset[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Dim Appointment As Object[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Dim objOutlook As Outlook.Application[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Dim objAppt As Outlook.AppointmentItem[/FONT][/COLOR]
[COLOR=red][FONT=Verdana]'Dim objRecurPattern As Outlook.RecurrencePattern[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set objOutlook = CreateObject("Outlook.Application")[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set objAppt = objOutlook.CreateItem(olAppointmentItem)[/FONT][/COLOR]
[COLOR=red][FONT=Verdana]Set objRecurPattern = objOutlook.CreateItem(olAppointmentItem)[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]'set up database to receive tasks[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set db = CurrentDb[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set rs = db.OpenRecordset("tblShowAllOutlookTasks", DB_OPEN_DYNASET)[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]' Set the Application object.[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set ol = New Outlook.Application[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]' Set the Namespace object.[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set olns = ol.GetNamespace("MAPI")[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]'Set the default appointment folder.[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set objFolder = olns.GetDefaultFolder(olFolderCalendar)[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]' Set objAllTasks equal to the collection of all Tasks.[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set objAllAppointment = objFolder.Items[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]' Loop through each Appointment.[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]For Each Appointment In objAllAppointment[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]If Appointment.Categories = "CBBEP" Then[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs.AddNew[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("ProjectManagerID") = strAns1[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("typeofrecord") = "A"[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("olsubject") = Appointment.Subject[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("olstartdate") = Appointment.Start[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("olduedate") = Appointment.End[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("olreminderonoff") = Appointment.ReminderSet[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("Aduration") = Appointment.Duration[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("Aalldayevent") = Appointment.AllDayEvent[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("alocation") = Appointment.Location[/FONT][/COLOR]
[COLOR=red][FONT=Verdana]rs("arecurrencetype") = Appointment.RecurrencePattern.RecurrenceType[/FONT][/COLOR]
[COLOR=red][FONT=Verdana]rs("apatternEnddate") = Appointment.PatternEndDate[/FONT][/COLOR]
[COLOR=red][FONT=Verdana]rs("patternstartdate") = Appointment.PatternStartDate[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("AIsRecurring") = Appointment.IsRecurring[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("AReminderMinutesBeforeStart") = Appointment.ReminderMinutesBeforeStart[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("AReminderTime") = Appointment.ReminderTime[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]rs("olnotes") = Appointment.Body[/FONT][/COLOR]
[FONT=Verdana][COLOR=black]rs("olpriority") = Appointment.Importance[/COLOR][/FONT]
[COLOR=black][FONT=Verdana]rs.Update[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Else 'donothing[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]End If[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Next[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set rs = Nothing[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Set db = Nothing[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]End Function[/FONT][/COLOR]
Thanks,
Richard