PDA

View Full Version : VBA to modify appointment item in additional Exchange account doesn't work



sbueffel
11-14-2013, 12:03 PM
I am using 32-bit Outlook 2013. I am trying to modify properties of an existing, selected calendar item in an additional Exchange account in the profile (MultiEx). The code works against appointment items in the primary, i.e., first added, account in the profile. Additionally, it works against shared calendars that are open in the profile. It does not, however, work against selected appointment items in the calendar of the additional Exchange account.

Sub SetAvailandReminder()
Dim oAppt As Outlook.AppointmentItem
Set oAppt = Application.ActiveExplorer.Selection.Item(1)
oAppt.ReminderSet = False
oAppt.BusyStatus = olFree
oAppt.Save
End Sub

I don't get any error, just that the changes are not saved and reflected. I am able to display a MsgBox and output any of the properties of the item, so the selection object is correctly bound to the appointment item. I can't figure out why the same code works against the primary calendar and shared calendars, but not the multi-Ex account, even though it is correctly reading the appointment's properties.

Scott :banghead:

skatonni
11-14-2013, 08:49 PM
My only thought is that you do not have the permission. Try to manually update these fields.

sbueffel
11-15-2013, 08:29 AM
My only thought is that you do not have the permission. Try to manually update these fields.

Well, of course, I have permission. You can't open a mailbox in multi-ex if you don't have FMA. Manually changing the properties does work. My intent is to use the macro so I don't have to manually change them. I have code that successfully creates an item in any calendar I have a time block selected:

Sub CreateTravelAppointment(subject, starttime, duration, setreminder)
'Create appointment item
Set oFolder = Application.ActiveExplorer.CurrentFolder
Set myItem = oFolder.Items.Add("IPM.Appointment")
myItem.subject = subject
myItem.Start = starttime
myItem.duration = duration
myItem.BusyStatus = olOutOfOffice
If setreminder = False Then
myItem.ReminderSet = False
End If
myItem.Save
End Sub

This why I am so confused why the selection object code isn't working to modify an item only in the multi-Ex calendar, when I can create one in it just fine.

Scott