Bob Stamm
asked on
VBA to create Outlook Calendar Appointment
I have a Access project that I am using VBA to create Outlook Calendar Appointment. The following code creates a new appointment in the defult Calendar window of MS Outlook. Outlook allows you to create custom calendars under My Calendars. Is there a way to modify the VBA to direct the new appointment to a custom calendar? My calendar name is Project Schedule.
Ideas?
Bob
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objOutlook = CreateObject("Outlook.Appl ication")
Set objAppt = objOutlook.CreateItem(olAp pointmentI tem)
With objAppt
.Start = Me.datTargetStart
.End = Me.datProjectedCompletion
.Subject = Me.txtProjectName
.Location = Me.cboSystem
If Not IsNull(Me.txtProjectNotes) Then .Body = OutlookNotes
.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
Ideas?
Bob
Dim objOutlook As Outlook.Application
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objOutlook = CreateObject("Outlook.Appl
Set objAppt = objOutlook.CreateItem(olAp
With objAppt
.Start = Me.datTargetStart
.End = Me.datProjectedCompletion
.Subject = Me.txtProjectName
.Location = Me.cboSystem
If Not IsNull(Me.txtProjectNotes)
.Save
.Close (olSave)
End With
'Release the AppointmentItem object variable.
Set objAppt = Nothing
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> It looks to me that I will need to know their login name and code it into this line. Not a problem, but is that correct?
If they create that calendar in their online mailbox, then that's correct.
> Is the syntax correct?
Looks right to me.
If they create that calendar in their online mailbox, then that's correct.
> Is the syntax correct?
Looks right to me.
ASKER
BlueDevilFan,
I am getting a compile error. I pasted your code into my project. This last line highlights .Items and returns
"Method or data member not found."
Dim objOutlook As Outlook.Application
Dim objCalendar As Outlook.MAPIFolder
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objOutlook = CreateObject("Outlook.Appl ication")
Set objCalendar = OpenMAPIFolder("\Mailbox - Stamm,Bob\ProjectSchedule" )
Set objAppt = objCalendar.Items.Add
Ideas?
Thanks,
Bob
I am getting a compile error. I pasted your code into my project. This last line highlights .Items and returns
"Method or data member not found."
Dim objOutlook As Outlook.Application
Dim objCalendar As Outlook.MAPIFolder
Dim objAppt As Outlook.AppointmentItem
Dim objRecurPattern As Outlook.RecurrencePattern
Set objOutlook = CreateObject("Outlook.Appl
Set objCalendar = OpenMAPIFolder("\Mailbox - Stamm,Bob\ProjectSchedule"
Set objAppt = objCalendar.Items.Add
Ideas?
Thanks,
Bob
Hmmm. Every MAPIFolder object has an Items collection. All I can suggest is setting a breakpoint on that last line and when the code breaks take a look at objCalendar. Verify that it is of type MAPIFolder, and see if it contains an Items property.
ASKER
BlueDevilFan,
Thanks for your help.
Bpb
Thanks for your help.
Bpb
You're welcome.
ASKER
This may be a dumb question but...this line has me confused. I have this project as a FE/BE application with ~ 50 users. My thoughts were that if I instructed everyone to create a "Project Schedule" calender, they could use it to seperate their appointments. It looks to me that I will need to know their login name and code it into this line. Not a problem, but is that correct? Is the syntax correct?
Set objCalendar = OpenMAPIFolder("\Mailbox - Doe, John\Project Schedule")
I am capturing the users login name when they open my Access project. Therefore my code would be modified as:
LoginID = LastName & ", " & FirstName
Set objCalendar = OpenMAPIFolder("\Mailbox - " & LoginID & "\Project Schedule")
Thanks,
Bob